[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-user: gecos patch



Here is a patch for PCB that fixes the problem that the user name
is printed as "User Name,,," in the output Gerbers.

I already sent it but it seems that it went unnoticed.

CL<

--- pcb-20050609/src/print.c	2005-03-12 03:17:13.000000000 +0100
+++ pcb-20050609_new/src/print.c	2006-03-03 15:47:35.000000000 +0100
@@ -1358,9 +1358,22 @@
 	fab_author = Settings.FabAuthor;
       else
 	{
+	  int len;
+	  unsigned char *comma, *gecos;
+
 	  /* ID the user. */
 	  pwentry = getpwuid (getuid ());
-	  fab_author = pwentry->pw_gecos;
+	  gecos = pwentry->pw_gecos;
+	  comma=strchr(gecos,',');
+	  if (comma) len=comma-gecos;
+	  else len=strlen(gecos);
+	  fab_author=malloc(len+1);
+	  if (!fab_author){
+	    perror("pcb: out of memory.\n");
+	    exit(-1);
+	  }
+	  memcpy(fab_author, gecos, len);
+	  fab_author[len]=0;
 	}
     }
   return fab_author;