mkstr.c (50477) | mkstr.c (87289) |
---|---|
1/* 2 * Copyright (c) 1980, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 28 unchanged lines hidden (view full) --- 37 The Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint 41#if 0 42static char sccsid[] = "@(#)mkstr.c 8.1 (Berkeley) 6/6/93"; 43#endif 44static const char rcsid[] = | 1/* 2 * Copyright (c) 1980, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 28 unchanged lines hidden (view full) --- 37 The Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint 41#if 0 42static char sccsid[] = "@(#)mkstr.c 8.1 (Berkeley) 6/6/93"; 43#endif 44static const char rcsid[] = |
45 "$FreeBSD: head/usr.bin/mkstr/mkstr.c 50477 1999-08-28 01:08:13Z peter $"; | 45 "$FreeBSD: head/usr.bin/mkstr/mkstr.c 87289 2001-12-03 21:06:20Z dwmalone $"; |
46#endif /* not lint */ 47 48#include <err.h> 49#include <stdio.h> 50#include <stdlib.h> 51#include <string.h> 52 53#define ungetchar(c) ungetc(c, stdin) --- 26 unchanged lines hidden (view full) --- 80 81FILE *mesgread, *mesgwrite; 82char name[100], *np; 83 84void copystr __P((void)); 85int fgetNUL __P((char *, int, FILE *)); 86unsigned hashit __P((char *, char, unsigned)); 87void inithash __P((void)); | 46#endif /* not lint */ 47 48#include <err.h> 49#include <stdio.h> 50#include <stdlib.h> 51#include <string.h> 52 53#define ungetchar(c) ungetc(c, stdin) --- 26 unchanged lines hidden (view full) --- 80 81FILE *mesgread, *mesgwrite; 82char name[100], *np; 83 84void copystr __P((void)); 85int fgetNUL __P((char *, int, FILE *)); 86unsigned hashit __P((char *, char, unsigned)); 87void inithash __P((void)); |
88int match __P((char *)); | 88int match __P((const char *)); |
89int octdigit __P((char)); 90void process __P((void)); 91static void usage __P((void)); 92 93int 94main(argc, argv) 95 int argc; 96 char *argv[]; --- 33 unchanged lines hidden (view full) --- 130{ 131 fprintf(stderr, "usage: mkstr [ - ] mesgfile prefix file ...\n"); 132 exit(1); 133} 134 135void 136process() 137{ | 89int octdigit __P((char)); 90void process __P((void)); 91static void usage __P((void)); 92 93int 94main(argc, argv) 95 int argc; 96 char *argv[]; --- 33 unchanged lines hidden (view full) --- 130{ 131 fprintf(stderr, "usage: mkstr [ - ] mesgfile prefix file ...\n"); 132 exit(1); 133} 134 135void 136process() 137{ |
138 register c; | 138 int c; |
139 140 for (;;) { 141 c = getchar(); 142 if (c == EOF) 143 return; 144 if (c != 'e') { 145 putchar(c); 146 continue; --- 6 unchanged lines hidden (view full) --- 153 else 154 copystr(); 155 } 156 } 157} 158 159int 160match(ocp) | 139 140 for (;;) { 141 c = getchar(); 142 if (c == EOF) 143 return; 144 if (c != 'e') { 145 putchar(c); 146 continue; --- 6 unchanged lines hidden (view full) --- 153 else 154 copystr(); 155 } 156 } 157} 158 159int 160match(ocp) |
161 char *ocp; | 161 const char *ocp; |
162{ | 162{ |
163 register char *cp; 164 register c; | 163 const char *cp; 164 int c; |
165 166 for (cp = ocp + 1; *cp; cp++) { 167 c = getchar(); 168 if (c != *cp) { 169 while (ocp < cp) 170 putchar(*ocp++); 171 ungetchar(c); 172 return (0); 173 } 174 } 175 return (1); 176} 177 178void 179copystr() 180{ | 165 166 for (cp = ocp + 1; *cp; cp++) { 167 c = getchar(); 168 if (c != *cp) { 169 while (ocp < cp) 170 putchar(*ocp++); 171 ungetchar(c); 172 return (0); 173 } 174 } 175 return (1); 176} 177 178void 179copystr() 180{ |
181 register c, ch; | 181 int c, ch; |
182 char buf[512]; 183 register char *cp = buf; 184 185 for (;;) { 186 c = getchar(); 187 if (c == EOF) 188 break; 189 switch (c) { --- 129 unchanged lines hidden (view full) --- 319#include <sys/stat.h> 320 321int 322fgetNUL(obuf, rmdr, file) 323 char *obuf; 324 register int rmdr; 325 FILE *file; 326{ | 182 char buf[512]; 183 register char *cp = buf; 184 185 for (;;) { 186 c = getchar(); 187 if (c == EOF) 188 break; 189 switch (c) { --- 129 unchanged lines hidden (view full) --- 319#include <sys/stat.h> 320 321int 322fgetNUL(obuf, rmdr, file) 323 char *obuf; 324 register int rmdr; 325 FILE *file; 326{ |
327 register c; | 327 int c; |
328 register char *buf = obuf; 329 330 while (--rmdr > 0 && (c = getc(file)) != 0 && c != EOF) 331 *buf++ = c; 332 *buf++ = 0; 333 getc(file); 334 return ((feof(file) || ferror(file)) ? 0 : 1); 335} | 328 register char *buf = obuf; 329 330 while (--rmdr > 0 && (c = getc(file)) != 0 && c != EOF) 331 *buf++ = c; 332 *buf++ = 0; 333 getc(file); 334 return ((feof(file) || ferror(file)) ? 0 : 1); 335} |