Mercurial > emacs
comparison lib-src/sorted-doc.c @ 109111:52b76722152a
Convert function definitions to standard C.
* lib-src/update-game-score.c: Convert function definitions to standard C.
* lib-src/sorted-doc.c:
* lib-src/profile.c:
* lib-src/pop.c:
* lib-src/movemail.c:
* lib-src/make-docfile.c:
* lib-src/hexl.c:
* lib-src/fakemail.c:
* lib-src/etags.c:
* lib-src/ebrowse.c:
* lib-src/digest-doc.c:
* lib-src/b2m.c: Likewise.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Fri, 02 Jul 2010 17:50:23 -0700 |
parents | 1d1d5d9bd884 |
children | 71150397fb59 |
comparison
equal
deleted
inserted
replaced
109110:25749a68f5ae | 109111:52b76722152a |
---|---|
63 | 63 |
64 | 64 |
65 /* Print error message. `s1' is printf control string, `s2' is arg for it. */ | 65 /* Print error message. `s1' is printf control string, `s2' is arg for it. */ |
66 | 66 |
67 void | 67 void |
68 error (s1, s2) | 68 error (char *s1, char *s2) |
69 char *s1, *s2; | |
70 { | 69 { |
71 fprintf (stderr, "sorted-doc: "); | 70 fprintf (stderr, "sorted-doc: "); |
72 fprintf (stderr, s1, s2); | 71 fprintf (stderr, s1, s2); |
73 fprintf (stderr, "\n"); | 72 fprintf (stderr, "\n"); |
74 } | 73 } |
75 | 74 |
76 /* Print error message and exit. */ | 75 /* Print error message and exit. */ |
77 | 76 |
78 void | 77 void |
79 fatal (s1, s2) | 78 fatal (char *s1, char *s2) |
80 char *s1, *s2; | |
81 { | 79 { |
82 error (s1, s2); | 80 error (s1, s2); |
83 exit (EXIT_FAILURE); | 81 exit (EXIT_FAILURE); |
84 } | 82 } |
85 | 83 |
86 /* Like malloc but get fatal error if memory is exhausted. */ | 84 /* Like malloc but get fatal error if memory is exhausted. */ |
87 | 85 |
88 char * | 86 char * |
89 xmalloc (size) | 87 xmalloc (int size) |
90 int size; | |
91 { | 88 { |
92 char *result = malloc ((unsigned)size); | 89 char *result = malloc ((unsigned)size); |
93 if (result == NULL) | 90 if (result == NULL) |
94 fatal ("%s", "virtual memory exhausted"); | 91 fatal ("%s", "virtual memory exhausted"); |
95 return result; | 92 return result; |
96 } | 93 } |
97 | 94 |
98 char * | 95 char * |
99 xstrdup (str) | 96 xstrdup (char *str) |
100 char * str; | |
101 { | 97 { |
102 char *buf = xmalloc (strlen (str) + 1); | 98 char *buf = xmalloc (strlen (str) + 1); |
103 (void) strcpy (buf, str); | 99 (void) strcpy (buf, str); |
104 return (buf); | 100 return (buf); |
105 } | 101 } |
106 | 102 |
107 /* Comparison function for qsort to call. */ | 103 /* Comparison function for qsort to call. */ |
108 | 104 |
109 int | 105 int |
110 cmpdoc (a, b) | 106 cmpdoc (DOCSTR **a, DOCSTR **b) |
111 DOCSTR **a; | |
112 DOCSTR **b; | |
113 { | 107 { |
114 register int val = strcmp ((*a)->name, (*b)->name); | 108 register int val = strcmp ((*a)->name, (*b)->name); |
115 if (val) return val; | 109 if (val) return val; |
116 return (*a)->type - (*b)->type; | 110 return (*a)->type - (*b)->type; |
117 } | 111 } |
126 { | 120 { |
127 "WAITING", "BEG_NAME", "NAME_GET", "BEG_DESC", "DESC_GET" | 121 "WAITING", "BEG_NAME", "NAME_GET", "BEG_DESC", "DESC_GET" |
128 }; | 122 }; |
129 | 123 |
130 int | 124 int |
131 main () | 125 main (void) |
132 { | 126 { |
133 register DOCSTR *dp = NULL; /* allocated DOCSTR */ | 127 register DOCSTR *dp = NULL; /* allocated DOCSTR */ |
134 register LINE *lp = NULL; /* allocated line */ | 128 register LINE *lp = NULL; /* allocated line */ |
135 register char *bp; /* ptr inside line buffer */ | 129 register char *bp; /* ptr inside line buffer */ |
136 register enum state state = WAITING; /* state at start */ | 130 register enum state state = WAITING; /* state at start */ |