Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: getline(3) and tools for stable branches



roy%NetBSD.org@localhost wrote:
> > Could you please send a pullup request?
> 
> pullup-5 #885 requested pulls up everything that applies cleanly.

Thanks.

netbsd-4 also has the same problem but there are too many conflicts,
so it might be better to pullup only necessary changes for host tools
(ctags, pax, gencat). (note nawk is not in tools on netbsd-4)

The following ones can be applied cleanly:
cvs update -kk -j1.18 -j1.19 usr.bin/ctags/C.c
cvs update -kk -j1.8 -j1.9 usr.bin/ctags/ctags.h
cvs update -kk -j1.10 -j1.11 usr.bin/ctags/fortran.c usr.bin/ctags/lisp.c
cvs update -kk -j1.9 -j1.10 usr.bin/ctags/print.c
cvs update -kk -j1.11 -j1.12 usr.bin/ctags/yacc.c

The following changes cause conflicts due to ANSIfy decls:
cvs update -kk -j1.104 -j1.105 bin/pax/options.c
cvs update -kk -j1.29 -j1.30 usr.bin/gencat/gencat.c

Patches for these two files are trivial.
---
Index: bin/pax/options.c
===================================================================
RCS file: /cvsroot/src/bin/pax/options.c,v
retrieving revision 1.98
diff -u -r1.98 options.c
--- bin/pax/options.c   16 Oct 2006 00:11:22 -0000      1.98
+++ bin/pax/options.c   1 Aug 2009 11:05:08 -0000
@@ -85,7 +85,7 @@
 static void printflg(unsigned int);
 static int c_frmt(const void *, const void *);
 static off_t str_offt(char *);
-static char *getline(FILE *fp);
+static char *get_line(FILE *fp);
 static void pax_options(int, char **);
 static void pax_usage(void);
 static void tar_options(int, char **);
@@ -95,10 +95,10 @@
 static void cpio_usage(void);
 #endif
 
-/* errors from getline */
+/* errors from get_line */
 #define GETLINE_FILE_CORRUPT 1
 #define GETLINE_OUT_OF_MEM 2
-static int getline_error;
+static int get_line_error;
 
 #define BZIP2_CMD      "bzip2"         /* command to run as bzip2 */
 #define GZIP_CMD       "gzip"          /* command to run as gzip */
@@ -1183,7 +1183,7 @@
                                                tty_warn(1, "Unable to open 
file '%s' for read", file);
                                                tar_usage();
                                        }
-                                       while ((str = getline(fp)) != NULL) {
+                                       while ((str = get_line(fp)) != NULL) {
                                                if (dirisnext) {
                                                        if (dir)
                                                                free(dir);
@@ -1216,7 +1216,7 @@
                                                free(dir);
                                        if (strcmp(file, "-") != 0)
                                                fclose(fp);
-                                       if (getline_error) {
+                                       if (get_line_error) {
                                                tty_warn(1, "Problem with file 
'%s'", file);
                                                tar_usage();
                                        }
@@ -1286,7 +1286,7 @@
                                        tty_warn(1, "Unable to open file '%s' 
for read", file);
                                        tar_usage();
                                }
-                               while ((str = getline(fp)) != NULL) {
+                               while ((str = get_line(fp)) != NULL) {
                                        if (dirisnext) {
                                                if (ftree_add(str, 1) < 0)
                                                        tar_usage();
@@ -1310,7 +1310,7 @@
                                        tar_usage();
                                if (strcmp(file, "-") != 0)
                                        fclose(fp);
-                               if (getline_error) {
+                               if (get_line_error) {
                                        tty_warn(1, "Problem with file '%s'",
                                            file);
                                        tar_usage();
@@ -1598,11 +1598,11 @@
                                    optarg);
                                cpio_usage();
                        }
-                       while ((str = getline(fp)) != NULL) {
+                       while ((str = get_line(fp)) != NULL) {
                                pat_add(str, NULL);
                        }
                        fclose(fp);
-                       if (getline_error) {
+                       if (get_line_error) {
                                tty_warn(1, "Problem with file '%s'", optarg);
                                cpio_usage();
                        }
@@ -1754,10 +1754,10 @@
                 * no read errors allowed on updates/append operation!
                 */
                maxflt = 0;
-               while ((str = getline(stdin)) != NULL) {
+               while ((str = get_line(stdin)) != NULL) {
                        ftree_add(str, 0);
                }
-               if (getline_error) {
+               if (get_line_error) {
                        tty_warn(1, "Problem while reading stdin");
                        cpio_usage();
                }
@@ -1985,21 +1985,21 @@
 }
 
 char *
-getline(FILE *f)
+get_line(FILE *f)
 {
        char *name, *temp;
        size_t len;
 
        name = fgetln(f, &len);
        if (!name) {
-               getline_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0;
+               get_line_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0;
                return 0;
        }
        if (name[len-1] != '\n')
                len++;
        temp = malloc(len);
        if (!temp) {
-               getline_error = GETLINE_OUT_OF_MEM;
+               get_line_error = GETLINE_OUT_OF_MEM;
                return 0;
        }
        memcpy(temp, name, len-1);
Index: usr.bin/gencat/gencat.c
===================================================================
RCS file: /cvsroot/src/usr.bin/gencat/gencat.c,v
retrieving revision 1.20
diff -u -r1.20 gencat.c
--- usr.bin/gencat/gencat.c     30 Mar 2006 20:32:10 -0000      1.20
+++ usr.bin/gencat/gencat.c     1 Aug 2009 11:05:09 -0000
@@ -126,7 +126,7 @@
 static char   *cskip __P((char *));
 static void    error __P((char *, char *));
 static void    nomem __P((void));
-static char   *getline __P((int));
+static char   *get_line __P((int));
 static char   *getmsg __P((int, char *, char));
 static void    warning __P((char *, char *));
 static char   *wskip __P((char *));
@@ -262,7 +262,7 @@
 }
 
 static char *
-getline(fd)
+get_line(fd)
        int     fd;
 {
        static long curlen = BUFSIZ;
@@ -371,7 +371,7 @@
                                ++cptr;
                                switch (*cptr) {
                                case '\0':
-                                       cptr = getline(fd);
+                                       cptr = get_line(fd);
                                        if (!cptr)
                                                error(NULL, "premature end of 
file");
                                        msglen += strlen(cptr);
@@ -444,7 +444,7 @@
 
        /* XXX: init sethead? */
 
-       while ((cptr = getline(fd))) {
+       while ((cptr = get_line(fd))) {
                if (*cptr == '$') {
                        ++cptr;
                        if (strncmp(cptr, "set", 3) == 0) {

---
Izumi Tsutsui


Home | Main Index | Thread Index | Old Index