=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/patch/inp.c,v retrieving revision 1.21 retrieving revision 1.22 diff -c -r1.21 -r1.22 *** src/usr.bin/patch/inp.c 2003/07/31 14:10:21 1.21 --- src/usr.bin/patch/inp.c 2003/08/01 20:30:48 1.22 *************** *** 1,7 **** ! /* $OpenBSD: inp.c,v 1.21 2003/07/31 14:10:21 otto Exp $ */ #ifndef lint ! static const char rcsid[] = "$OpenBSD: inp.c,v 1.21 2003/07/31 14:10:21 otto Exp $"; #endif /* not lint */ #include --- 1,7 ---- ! /* $OpenBSD: inp.c,v 1.22 2003/08/01 20:30:48 otto Exp $ */ #ifndef lint ! static const char rcsid[] = "$OpenBSD: inp.c,v 1.22 2003/08/01 20:30:48 otto Exp $"; #endif /* not lint */ #include *************** *** 53,59 **** i_womp = NULL; i_ptr = NULL; } else { ! using_plan_a = TRUE; /* maybe the next one is smaller */ close(tifd); tifd = -1; free(tibuf[0]); --- 53,59 ---- i_womp = NULL; i_ptr = NULL; } else { ! using_plan_a = true; /* maybe the next one is smaller */ close(tifd); tifd = -1; free(tibuf[0]); *************** *** 88,94 **** struct stat filestat; if (filename == NULL || *filename == '\0') ! return FALSE; statfailed = stat(filename, &filestat); if (statfailed && ok_to_create_file) { --- 88,94 ---- struct stat filestat; if (filename == NULL || *filename == '\0') ! return false; statfailed = stat(filename, &filestat); if (statfailed && ok_to_create_file) { *************** *** 101,108 **** * to normal patch behavior as possible */ if (check_only) ! return TRUE; ! makedirs(filename, TRUE); close(creat(filename, 0666)); statfailed = stat(filename, &filestat); } --- 101,108 ---- * to normal patch behavior as possible */ if (check_only) ! return true; ! makedirs(filename, true); close(creat(filename, 0666)); statfailed = stat(filename, &filestat); } *************** *** 178,198 **** i_size = filestat.st_size; if (out_of_mem) { set_hunkmax(); /* make sure dynamic arrays are allocated */ ! out_of_mem = FALSE; ! return FALSE; /* force plan b because plan a bombed */ } if (i_size > SIZE_MAX - 2) fatal("block too large to allocate"); i_womp = malloc((size_t)(i_size + 2)); if (i_womp == NULL) ! return FALSE; if ((ifd = open(filename, O_RDONLY)) < 0) pfatal("can't open file %s", filename); if (read(ifd, i_womp, (size_t) i_size) != i_size) { close(ifd); /* probably means i_size > 15 or 16 bits worth */ free(i_womp); /* at this point it doesn't matter if i_womp was */ ! return FALSE; /* undersized. */ } close(ifd); --- 178,198 ---- i_size = filestat.st_size; if (out_of_mem) { set_hunkmax(); /* make sure dynamic arrays are allocated */ ! out_of_mem = false; ! return false; /* force plan b because plan a bombed */ } if (i_size > SIZE_MAX - 2) fatal("block too large to allocate"); i_womp = malloc((size_t)(i_size + 2)); if (i_womp == NULL) ! return false; if ((ifd = open(filename, O_RDONLY)) < 0) pfatal("can't open file %s", filename); if (read(ifd, i_womp, (size_t) i_size) != i_size) { close(ifd); /* probably means i_size > 15 or 16 bits worth */ free(i_womp); /* at this point it doesn't matter if i_womp was */ ! return false; /* undersized. */ } close(ifd); *************** *** 212,218 **** if (i_ptr == NULL) { /* shucks, it was a near thing */ free(i_womp); ! return FALSE; } /* now scan the buffer and build pointer array */ --- 212,218 ---- if (i_ptr == NULL) { /* shucks, it was a near thing */ free(i_womp); ! return false; } /* now scan the buffer and build pointer array */ *************** *** 248,254 **** say("Good. This file appears to be the %s version.\n", revision); } ! return TRUE; /* plan a will work */ } /* Keep (virtually) nothing in memory. */ --- 248,254 ---- say("Good. This file appears to be the %s version.\n", revision); } ! return true; /* plan a will work */ } /* Keep (virtually) nothing in memory. */ *************** *** 260,266 **** int i = 0, maxlen = 1; bool found_revision = (revision == NULL); ! using_plan_a = FALSE; if ((ifp = fopen(filename, "r")) == NULL) pfatal("can't open file %s", filename); (void) unlink(TMPINNAME); --- 260,266 ---- int i = 0, maxlen = 1; bool found_revision = (revision == NULL); ! using_plan_a = false; if ((ifp = fopen(filename, "r")) == NULL) pfatal("can't open file %s", filename); (void) unlink(TMPINNAME); *************** *** 268,274 **** pfatal("can't open file %s", TMPINNAME); while (fgets(buf, sizeof buf, ifp) != NULL) { if (revision != NULL && !found_revision && rev_in_string(buf)) ! found_revision = TRUE; if ((i = strlen(buf)) > maxlen) maxlen = i; /* find longest line */ } --- 268,274 ---- pfatal("can't open file %s", TMPINNAME); while (fgets(buf, sizeof buf, ifp) != NULL) { if (revision != NULL && !found_revision && rev_in_string(buf)) ! found_revision = true; if ((i = strlen(buf)) > maxlen) maxlen = i; /* find longest line */ } *************** *** 331,337 **** if (line < 1 || line > input_lines) { if (warn_on_invalid_line) { say("No such line %ld in input file, ignoring\n", line); ! warn_on_invalid_line = FALSE; } return NULL; } --- 331,337 ---- if (line < 1 || line > input_lines) { if (warn_on_invalid_line) { say("No such line %ld in input file, ignoring\n", line); ! warn_on_invalid_line = false; } return NULL; } *************** *** 368,382 **** int patlen; if (revision == NULL) ! return TRUE; patlen = strlen(revision); if (strnEQ(string, revision, patlen) && isspace(string[patlen])) ! return TRUE; for (s = string; *s; s++) { if (isspace(*s) && strnEQ(s + 1, revision, patlen) && isspace(s[patlen + 1])) { ! return TRUE; } } ! return FALSE; } --- 368,382 ---- int patlen; if (revision == NULL) ! return true; patlen = strlen(revision); if (strnEQ(string, revision, patlen) && isspace(string[patlen])) ! return true; for (s = string; *s; s++) { if (isspace(*s) && strnEQ(s + 1, revision, patlen) && isspace(s[patlen + 1])) { ! return true; } } ! return false; }