diff options
| author | Ken Raeburn | 2001-07-06 08:41:36 +0000 |
|---|---|---|
| committer | Ken Raeburn | 2001-07-06 08:41:36 +0000 |
| commit | ad782551325b7c694ee234b5ff4c5688d90e561c (patch) | |
| tree | f4355f141142b6018183518fa1761b53e295ede2 /lib-src | |
| parent | f25cfe53951f57e1b2c3972877297df3d86bb980 (diff) | |
| download | emacs-ad782551325b7c694ee234b5ff4c5688d90e561c.tar.gz emacs-ad782551325b7c694ee234b5ff4c5688d90e561c.zip | |
properly mark Attic files as deleted
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/env.c | 353 | ||||
| -rw-r--r-- | lib-src/etags-vmslib.c | 155 | ||||
| -rw-r--r-- | lib-src/make-path.c | 105 | ||||
| -rwxr-xr-x | lib-src/rcs2log | 679 | ||||
| -rw-r--r-- | lib-src/timer.c | 368 | ||||
| -rw-r--r-- | lib-src/wakeup.c | 53 |
6 files changed, 0 insertions, 1713 deletions
diff --git a/lib-src/env.c b/lib-src/env.c deleted file mode 100644 index 2ae81a630b8..00000000000 --- a/lib-src/env.c +++ /dev/null | |||
| @@ -1,353 +0,0 @@ | |||
| 1 | /* env - manipulate environment and execute a program in that environment | ||
| 2 | Copyright (C) 1986, 1994 Free Software Foundation, Inc. | ||
| 3 | |||
| 4 | This program is free software; you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation; either version 2, or (at your option) | ||
| 7 | any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program; if not, write to the Free Software | ||
| 16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | ||
| 17 | |||
| 18 | /* Mly 861126 */ | ||
| 19 | |||
| 20 | /* If first argument is "-", then a new environment is constructed | ||
| 21 | from scratch; otherwise the environment is inherited from the parent | ||
| 22 | process, except as modified by other options. | ||
| 23 | |||
| 24 | So, "env - foo" will invoke the "foo" program in a null environment, | ||
| 25 | whereas "env foo" would invoke "foo" in the same environment as that | ||
| 26 | passed to "env" itself. | ||
| 27 | |||
| 28 | Subsequent arguments are interpreted as follows: | ||
| 29 | |||
| 30 | * "variable=value" (i.e., an arg containing a "=" character) | ||
| 31 | means to set the specified environment variable to that value. | ||
| 32 | `value' may be of zero length ("variable="). Note that setting | ||
| 33 | a variable to a zero-length value is different from unsetting it. | ||
| 34 | |||
| 35 | * "-u variable" or "-unset variable" | ||
| 36 | means to unset that variable. | ||
| 37 | If that variable isn't set, does nothing. | ||
| 38 | |||
| 39 | * "-s variable value" or "-set variable value" | ||
| 40 | same as "variable=value". | ||
| 41 | |||
| 42 | * "-" or "--" | ||
| 43 | are used to indicate that the following argument is the program | ||
| 44 | to invoke. This is only necessary when the program's name | ||
| 45 | begins with "-" or contains a "=". | ||
| 46 | |||
| 47 | * anything else | ||
| 48 | The first remaining argument specifies a program to invoke | ||
| 49 | (it is searched for according to the specification of the PATH | ||
| 50 | environment variable) and any arguments following that are | ||
| 51 | passed as arguments to that program. | ||
| 52 | |||
| 53 | If no program-name is specified following the environment | ||
| 54 | specifications, the resulting environment is printed. | ||
| 55 | This is like specifying a program-name of "printenv". | ||
| 56 | |||
| 57 | Examples: | ||
| 58 | If the environment passed to "env" is | ||
| 59 | { USER=rms EDITOR=emacs PATH=.:/gnubin:/hacks } | ||
| 60 | |||
| 61 | * "env DISPLAY=gnu:0 nemacs" | ||
| 62 | calls "nemacs" in the environment | ||
| 63 | { USER=rms EDITOR=emacs PATH=.:/gnubin:/hacks DISPLAY=gnu:0 } | ||
| 64 | |||
| 65 | * "env - USER=foo /hacks/hack bar baz" | ||
| 66 | calls the "hack" program on arguments "bar" and "baz" | ||
| 67 | in an environment in which the only variable is "USER". | ||
| 68 | Note that the "-" option clears out the PATH variable, | ||
| 69 | so one should be careful to specify in which directory | ||
| 70 | to find the program to call. | ||
| 71 | |||
| 72 | * "env -u EDITOR USER=foo PATH=/energy -- e=mc2 bar baz" | ||
| 73 | The program "/energy/e=mc2" is called with environment | ||
| 74 | { USER=foo PATH=/energy } | ||
| 75 | */ | ||
| 76 | |||
| 77 | #ifdef EMACS | ||
| 78 | #define NO_SHORTNAMES | ||
| 79 | #include "../src/config.h" | ||
| 80 | #endif /* EMACS */ | ||
| 81 | |||
| 82 | #include <stdio.h> | ||
| 83 | |||
| 84 | extern int execvp (); | ||
| 85 | |||
| 86 | char *xmalloc (), *xrealloc (); | ||
| 87 | char *concat (); | ||
| 88 | |||
| 89 | extern char **environ; | ||
| 90 | |||
| 91 | char **nenv; | ||
| 92 | int nenv_size; | ||
| 93 | |||
| 94 | char *progname; | ||
| 95 | void setenv (); | ||
| 96 | void fatal (); | ||
| 97 | char *myindex (); | ||
| 98 | |||
| 99 | extern char *strerror (); | ||
| 100 | |||
| 101 | |||
| 102 | main (argc, argv, envp) | ||
| 103 | register int argc; | ||
| 104 | register char **argv; | ||
| 105 | char **envp; | ||
| 106 | { | ||
| 107 | register char *tem; | ||
| 108 | |||
| 109 | progname = argv[0]; | ||
| 110 | argc--; | ||
| 111 | argv++; | ||
| 112 | |||
| 113 | nenv_size = 100; | ||
| 114 | nenv = (char **) xmalloc (nenv_size * sizeof (char *)); | ||
| 115 | *nenv = (char *) 0; | ||
| 116 | |||
| 117 | /* "-" flag means to not inherit parent's environment */ | ||
| 118 | if (argc && !strcmp (*argv, "-")) | ||
| 119 | { | ||
| 120 | argc--; | ||
| 121 | argv++; | ||
| 122 | } | ||
| 123 | else | ||
| 124 | /* Else pass on existing env vars. */ | ||
| 125 | for (; *envp; envp++) | ||
| 126 | { | ||
| 127 | tem = myindex (*envp, '='); | ||
| 128 | if (tem) | ||
| 129 | { | ||
| 130 | *tem = '\000'; | ||
| 131 | setenv (*envp, tem + 1); | ||
| 132 | } | ||
| 133 | } | ||
| 134 | |||
| 135 | while (argc > 0) | ||
| 136 | { | ||
| 137 | tem = myindex (*argv, '='); | ||
| 138 | if (tem) | ||
| 139 | /* If arg contains a "=" it specifies to set a variable */ | ||
| 140 | { | ||
| 141 | *tem = '\000'; | ||
| 142 | setenv (*argv, tem + 1); | ||
| 143 | argc--; | ||
| 144 | argv++; | ||
| 145 | continue; | ||
| 146 | } | ||
| 147 | |||
| 148 | if (**argv != '-') | ||
| 149 | /* Remaining args are program name and args to pass it */ | ||
| 150 | break; | ||
| 151 | |||
| 152 | if (argc < 2) | ||
| 153 | fatal ("no argument for `%s' option", *argv); | ||
| 154 | if (!strcmp (*argv, "-u") | ||
| 155 | || !strcmp (*argv, "-unset")) | ||
| 156 | /* Unset a variable */ | ||
| 157 | { | ||
| 158 | argc--; | ||
| 159 | argv++; | ||
| 160 | setenv (*argv, (char *) 0); | ||
| 161 | argc--; | ||
| 162 | argv++; | ||
| 163 | } | ||
| 164 | else if (!strcmp (*argv, "-s") || | ||
| 165 | !strcmp (*argv, "-set")) | ||
| 166 | /* Set a variable */ | ||
| 167 | { | ||
| 168 | argc--; | ||
| 169 | argv++; | ||
| 170 | tem = *argv; | ||
| 171 | if (argc < 2) | ||
| 172 | fatal ("no value specified for variable \"%s\"", tem); | ||
| 173 | argc--; | ||
| 174 | argv++; | ||
| 175 | setenv (tem, *argv); | ||
| 176 | argc--; | ||
| 177 | argv++; | ||
| 178 | } | ||
| 179 | else if (!strcmp (*argv, "-") || !strcmp (*argv, "--")) | ||
| 180 | { | ||
| 181 | argc--; | ||
| 182 | argv++; | ||
| 183 | break; | ||
| 184 | } | ||
| 185 | else | ||
| 186 | { | ||
| 187 | fatal ("unrecognized option `%s'", *argv); | ||
| 188 | } | ||
| 189 | } | ||
| 190 | |||
| 191 | /* If no program specified print the environment and exit */ | ||
| 192 | if (argc <= 0) | ||
| 193 | { | ||
| 194 | while (*nenv) | ||
| 195 | printf ("%s\n", *nenv++); | ||
| 196 | exit (0); | ||
| 197 | } | ||
| 198 | else | ||
| 199 | { | ||
| 200 | extern int errno; | ||
| 201 | extern char *strerror (); | ||
| 202 | |||
| 203 | environ = nenv; | ||
| 204 | (void) execvp (*argv, argv); | ||
| 205 | |||
| 206 | fprintf (stderr, "%s: cannot execute `%s': %s\n", | ||
| 207 | progname, *argv, strerror (errno)); | ||
| 208 | exit (errno != 0 ? errno : 1); | ||
| 209 | } | ||
| 210 | } | ||
| 211 | |||
| 212 | void | ||
| 213 | setenv (var, val) | ||
| 214 | register char *var, *val; | ||
| 215 | { | ||
| 216 | register char **e; | ||
| 217 | int len = strlen (var); | ||
| 218 | |||
| 219 | { | ||
| 220 | register char *tem = myindex (var, '='); | ||
| 221 | if (tem) | ||
| 222 | fatal ("environment variable names can not contain `=': %s", var); | ||
| 223 | else if (*var == '\000') | ||
| 224 | fatal ("zero-length environment variable name specified"); | ||
| 225 | } | ||
| 226 | |||
| 227 | for (e = nenv; *e; e++) | ||
| 228 | if (!strncmp (var, *e, len) && (*e)[len] == '=') | ||
| 229 | { | ||
| 230 | if (val) | ||
| 231 | goto set; | ||
| 232 | else | ||
| 233 | do | ||
| 234 | { | ||
| 235 | *e = *(e + 1); | ||
| 236 | } while (*e++); | ||
| 237 | return; | ||
| 238 | } | ||
| 239 | |||
| 240 | if (!val) | ||
| 241 | return; /* Nothing to unset */ | ||
| 242 | |||
| 243 | len = e - nenv; | ||
| 244 | if (len + 1 >= nenv_size) | ||
| 245 | { | ||
| 246 | nenv_size += 100; | ||
| 247 | nenv = (char **) xrealloc (nenv, nenv_size * sizeof (char *)); | ||
| 248 | e = nenv + len; | ||
| 249 | } | ||
| 250 | |||
| 251 | set: | ||
| 252 | val = concat (var, "=", val); | ||
| 253 | if (*e) | ||
| 254 | free (*e); | ||
| 255 | else | ||
| 256 | *(e + 1) = (char *) 0; | ||
| 257 | *e = val; | ||
| 258 | return; | ||
| 259 | } | ||
| 260 | |||
| 261 | void | ||
| 262 | fatal (msg, arg1, arg2) | ||
| 263 | char *msg, *arg1, *arg2; | ||
| 264 | { | ||
| 265 | fprintf (stderr, "%s: ", progname); | ||
| 266 | fprintf (stderr, msg, arg1, arg2); | ||
| 267 | putc ('\n', stderr); | ||
| 268 | exit (1); | ||
| 269 | } | ||
| 270 | |||
| 271 | |||
| 272 | extern char *malloc (), *realloc (); | ||
| 273 | |||
| 274 | void | ||
| 275 | memory_fatal () | ||
| 276 | { | ||
| 277 | fatal ("virtual memory exhausted"); | ||
| 278 | } | ||
| 279 | |||
| 280 | char * | ||
| 281 | xmalloc (size) | ||
| 282 | int size; | ||
| 283 | { | ||
| 284 | register char *value; | ||
| 285 | value = (char *) malloc (size); | ||
| 286 | if (!value) | ||
| 287 | memory_fatal (); | ||
| 288 | return (value); | ||
| 289 | } | ||
| 290 | |||
| 291 | char * | ||
| 292 | xrealloc (ptr, size) | ||
| 293 | char *ptr; | ||
| 294 | int size; | ||
| 295 | { | ||
| 296 | register char *value; | ||
| 297 | value = (char *) realloc (ptr, size); | ||
| 298 | if (!value) | ||
| 299 | memory_fatal (); | ||
| 300 | return (value); | ||
| 301 | } | ||
| 302 | |||
| 303 | /* Return a newly-allocated string whose contents concatenate | ||
| 304 | those of S1, S2, S3. */ | ||
| 305 | |||
| 306 | char * | ||
| 307 | concat (s1, s2, s3) | ||
| 308 | char *s1, *s2, *s3; | ||
| 309 | { | ||
| 310 | int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3); | ||
| 311 | char *result = (char *) xmalloc (len1 + len2 + len3 + 1); | ||
| 312 | |||
| 313 | strcpy (result, s1); | ||
| 314 | strcpy (result + len1, s2); | ||
| 315 | strcpy (result + len1 + len2, s3); | ||
| 316 | result[len1 + len2 + len3] = 0; | ||
| 317 | |||
| 318 | return result; | ||
| 319 | } | ||
| 320 | |||
| 321 | /* Return a pointer to the first occurrence in STR of C, | ||
| 322 | or 0 if C does not occur. */ | ||
| 323 | |||
| 324 | char * | ||
| 325 | myindex (str, c) | ||
| 326 | char *str; | ||
| 327 | char c; | ||
| 328 | { | ||
| 329 | char *s = str; | ||
| 330 | |||
| 331 | while (*s) | ||
| 332 | { | ||
| 333 | if (*s == c) | ||
| 334 | return s; | ||
| 335 | s++; | ||
| 336 | } | ||
| 337 | return 0; | ||
| 338 | } | ||
| 339 | |||
| 340 | #ifndef HAVE_STRERROR | ||
| 341 | char * | ||
| 342 | strerror (errnum) | ||
| 343 | int errnum; | ||
| 344 | { | ||
| 345 | extern char *sys_errlist[]; | ||
| 346 | extern int sys_nerr; | ||
| 347 | |||
| 348 | if (errnum >= 0 && errnum < sys_nerr) | ||
| 349 | return sys_errlist[errnum]; | ||
| 350 | return (char *) "Unknown error"; | ||
| 351 | } | ||
| 352 | |||
| 353 | #endif /* ! HAVE_STRERROR */ | ||
diff --git a/lib-src/etags-vmslib.c b/lib-src/etags-vmslib.c deleted file mode 100644 index cddb68085f8..00000000000 --- a/lib-src/etags-vmslib.c +++ /dev/null | |||
| @@ -1,155 +0,0 @@ | |||
| 1 | /* File name wild card expansion for VMS. | ||
| 2 | This file is part of the etags program. | ||
| 3 | Copyright (C) 1987 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | This program is free software; you can redistribute it and/or modify | ||
| 6 | it under the terms of the GNU General Public License as published by | ||
| 7 | the Free Software Foundation; either version 2, or (at your option) | ||
| 8 | any later version. | ||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful, | ||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | GNU General Public License for more details. | ||
| 14 | |||
| 15 | You should have received a copy of the GNU General Public License | ||
| 16 | along with this program; if not, write to the Free Software | ||
| 17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | ||
| 18 | |||
| 19 | #include <stdio.h> | ||
| 20 | typedef char tbool; | ||
| 21 | |||
| 22 | /* This is a BUG! ANY arbitrary limit is a BUG! | ||
| 23 | Won't someone please fix this? */ | ||
| 24 | #define MAX_FILE_SPEC_LEN 255 | ||
| 25 | typedef struct { | ||
| 26 | short curlen; | ||
| 27 | char body[MAX_FILE_SPEC_LEN + 1]; | ||
| 28 | } vspec; | ||
| 29 | #define EOS '\0' | ||
| 30 | #define NO 0 | ||
| 31 | #define YES 1 | ||
| 32 | #define NULL 0 | ||
| 33 | |||
| 34 | /* gfnames - return in successive calls the | ||
| 35 | name of each file specified by all the remaining args in the command-line | ||
| 36 | expanding wild cards and | ||
| 37 | stepping over arguments when they have been processed completely | ||
| 38 | */ | ||
| 39 | char* | ||
| 40 | gfnames(pac, pav, p_error) | ||
| 41 | int *pac; | ||
| 42 | char **pav[]; | ||
| 43 | tbool *p_error; | ||
| 44 | { | ||
| 45 | static vspec filename = {MAX_FILE_SPEC_LEN, "\0"}; | ||
| 46 | short fn_exp(); | ||
| 47 | |||
| 48 | while (1) | ||
| 49 | if (*pac == 0) | ||
| 50 | { | ||
| 51 | *p_error = NO; | ||
| 52 | return(NULL); | ||
| 53 | } | ||
| 54 | else switch(fn_exp(&filename, **pav)) | ||
| 55 | { | ||
| 56 | case 1: | ||
| 57 | *p_error = NO; | ||
| 58 | return(filename.body); | ||
| 59 | break; | ||
| 60 | case 0: | ||
| 61 | --*pac; | ||
| 62 | ++*pav; | ||
| 63 | break; | ||
| 64 | default: | ||
| 65 | *p_error = YES; | ||
| 66 | return(filename.body); | ||
| 67 | break; | ||
| 68 | } | ||
| 69 | |||
| 70 | } | ||
| 71 | |||
| 72 | /* fn_exp - expand specification of list of file names | ||
| 73 | returning in each successive call the next filename matching the input | ||
| 74 | spec. The function expects that each in_spec passed | ||
| 75 | to it will be processed to completion; in particular, up to and | ||
| 76 | including the call following that in which the last matching name | ||
| 77 | is returned, the function ignores the value of in_spec, and will | ||
| 78 | only start processing a new spec with the following call. | ||
| 79 | If an error occurs, on return out_spec contains the value | ||
| 80 | of in_spec when the error occurred. | ||
| 81 | |||
| 82 | With each successive filename returned in out_spec, the | ||
| 83 | function's return value is one. When there are no more matching | ||
| 84 | names the function returns zero. If on the first call no file | ||
| 85 | matches in_spec, or there is any other error, -1 is returned. | ||
| 86 | */ | ||
| 87 | |||
| 88 | #include <rmsdef.h> | ||
| 89 | #include <descrip.h> | ||
| 90 | #define OUTSIZE MAX_FILE_SPEC_LEN | ||
| 91 | short | ||
| 92 | fn_exp(out, in) | ||
| 93 | vspec *out; | ||
| 94 | char *in; | ||
| 95 | { | ||
| 96 | static long context = 0; | ||
| 97 | static struct dsc$descriptor_s o; | ||
| 98 | static struct dsc$descriptor_s i; | ||
| 99 | static tbool pass1 = YES; | ||
| 100 | long status; | ||
| 101 | short retval; | ||
| 102 | |||
| 103 | if (pass1) | ||
| 104 | { | ||
| 105 | pass1 = NO; | ||
| 106 | o.dsc$a_pointer = (char *) out; | ||
| 107 | o.dsc$w_length = (short)OUTSIZE; | ||
| 108 | i.dsc$a_pointer = in; | ||
| 109 | i.dsc$w_length = (short)strlen(in); | ||
| 110 | i.dsc$b_dtype = DSC$K_DTYPE_T; | ||
| 111 | i.dsc$b_class = DSC$K_CLASS_S; | ||
| 112 | o.dsc$b_dtype = DSC$K_DTYPE_VT; | ||
| 113 | o.dsc$b_class = DSC$K_CLASS_VS; | ||
| 114 | } | ||
| 115 | if ( (status = lib$find_file(&i, &o, &context, 0, 0)) == RMS$_NORMAL) | ||
| 116 | { | ||
| 117 | out->body[out->curlen] = EOS; | ||
| 118 | return(1); | ||
| 119 | } | ||
| 120 | else if (status == RMS$_NMF) | ||
| 121 | retval = 0; | ||
| 122 | else | ||
| 123 | { | ||
| 124 | strcpy(out->body, in); | ||
| 125 | retval = -1; | ||
| 126 | } | ||
| 127 | lib$find_file_end(&context); | ||
| 128 | pass1 = YES; | ||
| 129 | return(retval); | ||
| 130 | } | ||
| 131 | |||
| 132 | #ifndef OLD /* Newer versions of VMS do provide `system'. */ | ||
| 133 | system(cmd) | ||
| 134 | char *cmd; | ||
| 135 | { | ||
| 136 | fprintf(stderr, "system() function not implemented under VMS\n"); | ||
| 137 | } | ||
| 138 | #endif | ||
| 139 | |||
| 140 | #define VERSION_DELIM ';' | ||
| 141 | char *massage_name(s) | ||
| 142 | char *s; | ||
| 143 | { | ||
| 144 | char *start = s; | ||
| 145 | |||
| 146 | for ( ; *s; s++) | ||
| 147 | if (*s == VERSION_DELIM) | ||
| 148 | { | ||
| 149 | *s = EOS; | ||
| 150 | break; | ||
| 151 | } | ||
| 152 | else | ||
| 153 | *s = tolower(*s); | ||
| 154 | return(start); | ||
| 155 | } | ||
diff --git a/lib-src/make-path.c b/lib-src/make-path.c deleted file mode 100644 index c4e5bf93144..00000000000 --- a/lib-src/make-path.c +++ /dev/null | |||
| @@ -1,105 +0,0 @@ | |||
| 1 | /* Make all the directories along a path. | ||
| 2 | Copyright (C) 1992 Free Software Foundation, Inc. | ||
| 3 | |||
| 4 | This file is part of GNU Emacs. | ||
| 5 | |||
| 6 | GNU Emacs is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | any later version. | ||
| 10 | |||
| 11 | GNU Emacs is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with GNU Emacs; see the file COPYING. If not, write to | ||
| 18 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | ||
| 19 | |||
| 20 | /* This program works like mkdir, except that it generates | ||
| 21 | intermediate directories if they don't exist. This is just like | ||
| 22 | the `mkdir -p' command on most systems; unfortunately, the mkdir | ||
| 23 | command on some of the purer BSD systems (like Mt. Xinu) don't have | ||
| 24 | that option. */ | ||
| 25 | |||
| 26 | #include <sys/types.h> | ||
| 27 | #include <sys/stat.h> | ||
| 28 | #include <stdio.h> | ||
| 29 | #include <errno.h> | ||
| 30 | |||
| 31 | extern int errno; | ||
| 32 | |||
| 33 | char *prog_name; | ||
| 34 | |||
| 35 | /* Create directory DIRNAME if it does not exist already. | ||
| 36 | Then give permission for everyone to read and search it. | ||
| 37 | Return 0 if successful, 1 if not. */ | ||
| 38 | |||
| 39 | int | ||
| 40 | touchy_mkdir (dirname) | ||
| 41 | char *dirname; | ||
| 42 | { | ||
| 43 | struct stat buf; | ||
| 44 | |||
| 45 | /* If DIRNAME already exists and is a directory, don't create. */ | ||
| 46 | if (! (stat (dirname, &buf) >= 0 | ||
| 47 | && (buf.st_mode & S_IFMT) == S_IFDIR)) | ||
| 48 | { | ||
| 49 | /* Otherwise, try to make it. If DIRNAME exists but isn't a directory, | ||
| 50 | this will signal an error. */ | ||
| 51 | if (mkdir (dirname, 0777) < 0) | ||
| 52 | { | ||
| 53 | fprintf (stderr, "%s: ", prog_name); | ||
| 54 | perror (dirname); | ||
| 55 | return 1; | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | /* Make sure everyone can look at this directory. */ | ||
| 60 | if (stat (dirname, &buf) < 0) | ||
| 61 | { | ||
| 62 | fprintf (stderr, "%s: ", prog_name); | ||
| 63 | perror (dirname); | ||
| 64 | return 1; | ||
| 65 | } | ||
| 66 | if (chmod (dirname, 0555 | (buf.st_mode & 0777)) < 0) | ||
| 67 | { | ||
| 68 | fprintf (stderr, "%s: ", prog_name); | ||
| 69 | perror (dirname); | ||
| 70 | } | ||
| 71 | |||
| 72 | return 0; | ||
| 73 | } | ||
| 74 | |||
| 75 | int | ||
| 76 | main (argc, argv) | ||
| 77 | int argc; | ||
| 78 | char **argv; | ||
| 79 | { | ||
| 80 | prog_name = *argv; | ||
| 81 | |||
| 82 | for (argc--, argv++; argc > 0; argc--, argv++) | ||
| 83 | { | ||
| 84 | char *dirname = *argv; | ||
| 85 | int i; | ||
| 86 | |||
| 87 | /* Stop at each slash in dirname and try to create the directory. | ||
| 88 | Skip any initial slash. */ | ||
| 89 | for (i = (dirname[0] == '/') ? 1 : 0; dirname[i]; i++) | ||
| 90 | if (dirname[i] == '/') | ||
| 91 | { | ||
| 92 | dirname[i] = '\0'; | ||
| 93 | if (touchy_mkdir (dirname) < 0) | ||
| 94 | goto next_dirname; | ||
| 95 | dirname[i] = '/'; | ||
| 96 | } | ||
| 97 | |||
| 98 | touchy_mkdir (dirname); | ||
| 99 | |||
| 100 | next_dirname: | ||
| 101 | ; | ||
| 102 | } | ||
| 103 | |||
| 104 | return 0; | ||
| 105 | } | ||
diff --git a/lib-src/rcs2log b/lib-src/rcs2log deleted file mode 100755 index dd49a04f3c2..00000000000 --- a/lib-src/rcs2log +++ /dev/null | |||
| @@ -1,679 +0,0 @@ | |||
| 1 | #! /bin/sh | ||
| 2 | |||
| 3 | # RCS to ChangeLog generator | ||
| 4 | |||
| 5 | # Generate a change log prefix from RCS files (perhaps in the CVS repository) | ||
| 6 | # and the ChangeLog (if any). | ||
| 7 | # Output the new prefix to standard output. | ||
| 8 | # You can edit this prefix by hand, and then prepend it to ChangeLog. | ||
| 9 | |||
| 10 | # Ignore log entries that start with `#'. | ||
| 11 | # Clump together log entries that start with `{topic} ', | ||
| 12 | # where `topic' contains neither white space nor `}'. | ||
| 13 | |||
| 14 | Help='The default FILEs are the files registered under the working directory. | ||
| 15 | Options: | ||
| 16 | |||
| 17 | -c CHANGELOG Output a change log prefix to CHANGELOG (default ChangeLog). | ||
| 18 | -h HOSTNAME Use HOSTNAME in change log entries (default current host). | ||
| 19 | -i INDENT Indent change log lines by INDENT spaces (default 8). | ||
| 20 | -l LENGTH Try to limit log lines to LENGTH characters (default 79). | ||
| 21 | -R If no FILEs are given and RCS is used, recurse through working directory. | ||
| 22 | -r OPTION Pass OPTION to subsidiary log command. | ||
| 23 | -t TABWIDTH Tab stops are every TABWIDTH characters (default 8). | ||
| 24 | -u "LOGIN<tab>FULLNAME<tab>MAILADDR" Assume LOGIN has FULLNAME and MAILADDR. | ||
| 25 | -v Append RCS revision to file names in log lines. | ||
| 26 | --help Output help. | ||
| 27 | --version Output version number. | ||
| 28 | |||
| 29 | Report bugs to <bug-gnu-emacs@gnu.org>.' | ||
| 30 | |||
| 31 | Id='$Id: rcs2log,v 1.46 2001/01/02 18:50:14 eggert Exp $' | ||
| 32 | |||
| 33 | # Copyright 1992, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc. | ||
| 34 | |||
| 35 | # This program is free software; you can redistribute it and/or modify | ||
| 36 | # it under the terms of the GNU General Public License as published by | ||
| 37 | # the Free Software Foundation; either version 2, or (at your option) | ||
| 38 | # any later version. | ||
| 39 | # | ||
| 40 | # This program is distributed in the hope that it will be useful, | ||
| 41 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 42 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 43 | # GNU General Public License for more details. | ||
| 44 | # | ||
| 45 | # You should have received a copy of the GNU General Public License | ||
| 46 | # along with this program; see the file COPYING. If not, write to the | ||
| 47 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
| 48 | # Boston, MA 02111-1307, USA. | ||
| 49 | |||
| 50 | Copyright='Copyright 1998 Free Software Foundation, Inc. | ||
| 51 | This program comes with NO WARRANTY, to the extent permitted by law. | ||
| 52 | You may redistribute copies of this program | ||
| 53 | under the terms of the GNU General Public License. | ||
| 54 | For more information about these matters, see the files named COPYING. | ||
| 55 | Author: Paul Eggert <eggert@twinsun.com>' | ||
| 56 | |||
| 57 | tab=' ' | ||
| 58 | nl=' | ||
| 59 | ' | ||
| 60 | |||
| 61 | # Parse options. | ||
| 62 | |||
| 63 | # defaults | ||
| 64 | : ${AWK=awk} | ||
| 65 | : ${TMPDIR=/tmp} | ||
| 66 | changelog=ChangeLog # change log file name | ||
| 67 | datearg= # rlog date option | ||
| 68 | hostname= # name of local host (if empty, will deduce it later) | ||
| 69 | indent=8 # indent of log line | ||
| 70 | length=79 # suggested max width of log line | ||
| 71 | logins= # login names for people we know fullnames and mailaddrs of | ||
| 72 | loginFullnameMailaddrs= # login<tab>fullname<tab>mailaddr triplets | ||
| 73 | logTZ= # time zone for log dates (if empty, use local time) | ||
| 74 | recursive= # t if we want recursive rlog | ||
| 75 | revision= # t if we want revision numbers | ||
| 76 | rlog_options= # options to pass to rlog | ||
| 77 | tabwidth=8 # width of horizontal tab | ||
| 78 | |||
| 79 | while : | ||
| 80 | do | ||
| 81 | case $1 in | ||
| 82 | -c) changelog=${2?}; shift;; | ||
| 83 | -i) indent=${2?}; shift;; | ||
| 84 | -h) hostname=${2?}; shift;; | ||
| 85 | -l) length=${2?}; shift;; | ||
| 86 | -[nu]) # -n is obsolescent; it is replaced by -u. | ||
| 87 | case $1 in | ||
| 88 | -n) case ${2?}${3?}${4?} in | ||
| 89 | *"$tab"* | *"$nl"*) | ||
| 90 | echo >&2 "$0: -n '$2' '$3' '$4': tabs, newlines not allowed" | ||
| 91 | exit 1 | ||
| 92 | esac | ||
| 93 | case $loginFullnameMailaddrs in | ||
| 94 | '') loginFullnameMailaddrs=$2$tab$3$tab$4;; | ||
| 95 | ?*) loginFullnameMailaddrs=$loginFullnameMailaddrs$nl$2$tab$3$tab$4 | ||
| 96 | esac | ||
| 97 | shift; shift; shift;; | ||
| 98 | -u) | ||
| 99 | # If $2 is not tab-separated, use colon for separator. | ||
| 100 | case ${2?} in | ||
| 101 | *"$nl"*) | ||
| 102 | echo >&2 "$0: -u '$2': newlines not allowed" | ||
| 103 | exit 1;; | ||
| 104 | *"$tab"*) | ||
| 105 | t=$tab;; | ||
| 106 | *) | ||
| 107 | t=: | ||
| 108 | esac | ||
| 109 | case $2 in | ||
| 110 | *"$t"*"$t"*"$t"*) | ||
| 111 | echo >&2 "$0: -u '$2': too many fields" | ||
| 112 | exit 1;; | ||
| 113 | *"$t"*"$t"*) | ||
| 114 | ;; | ||
| 115 | *) | ||
| 116 | echo >&2 "$0: -u '$2': not enough fields" | ||
| 117 | exit 1 | ||
| 118 | esac | ||
| 119 | case $loginFullnameMailaddrs in | ||
| 120 | '') loginFullnameMailaddrs=$2;; | ||
| 121 | ?*) loginFullnameMailaddrs=$loginFullnameMailaddrs$nl$2 | ||
| 122 | esac | ||
| 123 | shift | ||
| 124 | esac | ||
| 125 | case $logins in | ||
| 126 | '') logins=$login;; | ||
| 127 | ?*) logins=$logins$nl$login | ||
| 128 | esac | ||
| 129 | ;; | ||
| 130 | -r) | ||
| 131 | case $rlog_options in | ||
| 132 | '') rlog_options=${2?};; | ||
| 133 | ?*) rlog_options=$rlog_options$nl${2?} | ||
| 134 | esac | ||
| 135 | shift;; | ||
| 136 | -R) recursive=t;; | ||
| 137 | -t) tabwidth=${2?}; shift;; | ||
| 138 | -v) revision=t;; | ||
| 139 | --version) | ||
| 140 | set $Id | ||
| 141 | rcs2logVersion=$3 | ||
| 142 | echo >&2 "rcs2log (GNU Emacs) $rcs2logVersion$nl$Copyright" | ||
| 143 | exit 0;; | ||
| 144 | -*) echo >&2 "Usage: $0 [OPTION]... [FILE ...]$nl$Help" | ||
| 145 | case $1 in | ||
| 146 | --help) exit 0;; | ||
| 147 | *) exit 1 | ||
| 148 | esac;; | ||
| 149 | *) break | ||
| 150 | esac | ||
| 151 | shift | ||
| 152 | done | ||
| 153 | |||
| 154 | month_data=' | ||
| 155 | m[0]="Jan"; m[1]="Feb"; m[2]="Mar" | ||
| 156 | m[3]="Apr"; m[4]="May"; m[5]="Jun" | ||
| 157 | m[6]="Jul"; m[7]="Aug"; m[8]="Sep" | ||
| 158 | m[9]="Oct"; m[10]="Nov"; m[11]="Dec" | ||
| 159 | ' | ||
| 160 | |||
| 161 | |||
| 162 | # Put rlog output into $rlogout. | ||
| 163 | |||
| 164 | # If no rlog options are given, | ||
| 165 | # log the revisions checked in since the first ChangeLog entry. | ||
| 166 | # Since ChangeLog is only by date, some of these revisions may be duplicates of | ||
| 167 | # what's already in ChangeLog; it's the user's responsibility to remove them. | ||
| 168 | case $rlog_options in | ||
| 169 | '') | ||
| 170 | if test -s "$changelog" | ||
| 171 | then | ||
| 172 | e=' | ||
| 173 | /^[0-9]+-[0-9][0-9]-[0-9][0-9]/{ | ||
| 174 | # ISO 8601 date | ||
| 175 | print $1 | ||
| 176 | exit | ||
| 177 | } | ||
| 178 | /^... ... [ 0-9][0-9] [ 0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9]+ /{ | ||
| 179 | # old-fashioned date and time (Emacs 19.31 and earlier) | ||
| 180 | '"$month_data"' | ||
| 181 | year = $5 | ||
| 182 | for (i=0; i<=11; i++) if (m[i] == $2) break | ||
| 183 | dd = $3 | ||
| 184 | printf "%d-%02d-%02d\n", year, i+1, dd | ||
| 185 | exit | ||
| 186 | } | ||
| 187 | ' | ||
| 188 | d=`$AWK "$e" <"$changelog"` || exit | ||
| 189 | case $d in | ||
| 190 | ?*) datearg="-d>$d" | ||
| 191 | esac | ||
| 192 | fi | ||
| 193 | esac | ||
| 194 | |||
| 195 | # Use TZ specified by ChangeLog local variable, if any. | ||
| 196 | if test -s "$changelog" | ||
| 197 | then | ||
| 198 | extractTZ=' | ||
| 199 | /^.*change-log-time-zone-rule['"$tab"' ]*:['"$tab"' ]*"\([^"]*\)".*/{ | ||
| 200 | s//\1/; p; q | ||
| 201 | } | ||
| 202 | /^.*change-log-time-zone-rule['"$tab"' ]*:['"$tab"' ]*t.*/{ | ||
| 203 | s//UTC0/; p; q | ||
| 204 | } | ||
| 205 | ' | ||
| 206 | logTZ=`tail "$changelog" | sed -n "$extractTZ"` | ||
| 207 | case $logTZ in | ||
| 208 | ?*) TZ=$logTZ; export TZ | ||
| 209 | esac | ||
| 210 | fi | ||
| 211 | |||
| 212 | # If CVS is in use, examine its repository, not the normal RCS files. | ||
| 213 | if test ! -f CVS/Repository | ||
| 214 | then | ||
| 215 | rlog=rlog | ||
| 216 | repository= | ||
| 217 | else | ||
| 218 | rlog='cvs -q log' | ||
| 219 | repository=`sed 1q <CVS/Repository` || exit | ||
| 220 | test ! -f CVS/Root || CVSROOT=`cat <CVS/Root` || exit | ||
| 221 | case $CVSROOT in | ||
| 222 | *:/*) | ||
| 223 | # remote repository | ||
| 224 | ;; | ||
| 225 | *) | ||
| 226 | # local repository | ||
| 227 | case $repository in | ||
| 228 | /*) ;; | ||
| 229 | *) repository=${CVSROOT?}/$repository | ||
| 230 | esac | ||
| 231 | if test ! -d "$repository" | ||
| 232 | then | ||
| 233 | echo >&2 "$0: $repository: bad repository (see CVS/Repository)" | ||
| 234 | exit 1 | ||
| 235 | fi | ||
| 236 | esac | ||
| 237 | fi | ||
| 238 | |||
| 239 | # Use $rlog's -zLT option, if $rlog supports it. | ||
| 240 | case `$rlog -zLT 2>&1` in | ||
| 241 | *' option'*) ;; | ||
| 242 | *) | ||
| 243 | case $rlog_options in | ||
| 244 | '') rlog_options=-zLT;; | ||
| 245 | ?*) rlog_options=-zLT$nl$rlog_options | ||
| 246 | esac | ||
| 247 | esac | ||
| 248 | |||
| 249 | # With no arguments, examine all files under the RCS directory. | ||
| 250 | case $# in | ||
| 251 | 0) | ||
| 252 | case $repository in | ||
| 253 | '') | ||
| 254 | oldIFS=$IFS | ||
| 255 | IFS=$nl | ||
| 256 | case $recursive in | ||
| 257 | t) | ||
| 258 | RCSdirs=`find . -name RCS -type d -print` | ||
| 259 | filesFromRCSfiles='s|,v$||; s|/RCS/|/|; s|^\./||' | ||
| 260 | files=` | ||
| 261 | { | ||
| 262 | case $RCSdirs in | ||
| 263 | ?*) find $RCSdirs \ | ||
| 264 | -type f \ | ||
| 265 | ! -name '*_' \ | ||
| 266 | ! -name ',*,' \ | ||
| 267 | ! -name '.*_' \ | ||
| 268 | ! -name .rcsfreeze.log \ | ||
| 269 | ! -name .rcsfreeze.ver \ | ||
| 270 | |||
| 271 | esac | ||
| 272 | find . -name '*,v' -print | ||
| 273 | } | | ||
| 274 | sort -u | | ||
| 275 | sed "$filesFromRCSfiles" | ||
| 276 | `;; | ||
| 277 | *) | ||
| 278 | files= | ||
| 279 | for file in RCS/.* RCS/* .*,v *,v | ||
| 280 | do | ||
| 281 | case $file in | ||
| 282 | RCS/. | RCS/.. | RCS/,*, | RCS/*_) continue;; | ||
| 283 | RCS/.rcsfreeze.log | RCS/.rcsfreeze.ver) continue;; | ||
| 284 | RCS/.\* | RCS/\* | .\*,v | \*,v) test -f "$file" || continue;; | ||
| 285 | RCS/*,v | RCS/.*,v) ;; | ||
| 286 | RCS/* | RCS/.*) test -f "$file" || continue | ||
| 287 | esac | ||
| 288 | case $files in | ||
| 289 | '') files=$file;; | ||
| 290 | ?*) files=$files$nl$file | ||
| 291 | esac | ||
| 292 | done | ||
| 293 | case $files in | ||
| 294 | '') exit 0 | ||
| 295 | esac | ||
| 296 | esac | ||
| 297 | set x $files | ||
| 298 | shift | ||
| 299 | IFS=$oldIFS | ||
| 300 | esac | ||
| 301 | esac | ||
| 302 | |||
| 303 | logdir=$TMPDIR/rcs2log$$ | ||
| 304 | llogout=$logdir/l | ||
| 305 | rlogout=$logdir/r | ||
| 306 | trap exit 1 2 13 15 | ||
| 307 | trap "rm -fr $logdir 2>/dev/null" 0 | ||
| 308 | (umask 077 && exec mkdir $logdir) || exit | ||
| 309 | |||
| 310 | case $datearg in | ||
| 311 | ?*) $rlog $rlog_options "$datearg" ${1+"$@"} >$rlogout;; | ||
| 312 | '') $rlog $rlog_options ${1+"$@"} >$rlogout | ||
| 313 | esac || exit | ||
| 314 | |||
| 315 | |||
| 316 | # Get the full name of each author the logs mention, and set initialize_fullname | ||
| 317 | # to awk code that initializes the `fullname' awk associative array. | ||
| 318 | # Warning: foreign authors (i.e. not known in the passwd file) are mishandled; | ||
| 319 | # you have to fix the resulting output by hand. | ||
| 320 | |||
| 321 | initialize_fullname= | ||
| 322 | initialize_mailaddr= | ||
| 323 | |||
| 324 | case $loginFullnameMailaddrs in | ||
| 325 | ?*) | ||
| 326 | case $loginFullnameMailaddrs in | ||
| 327 | *\"* | *\\*) | ||
| 328 | sed 's/["\\]/\\&/g' >$llogout <<EOF || exit | ||
| 329 | $loginFullnameMailaddrs | ||
| 330 | EOF | ||
| 331 | loginFullnameMailaddrs=`cat $llogout` | ||
| 332 | esac | ||
| 333 | |||
| 334 | oldIFS=$IFS | ||
| 335 | IFS=$nl | ||
| 336 | for loginFullnameMailaddr in $loginFullnameMailaddrs | ||
| 337 | do | ||
| 338 | case $loginFullnameMailaddr in | ||
| 339 | *"$tab"*) IFS=$tab;; | ||
| 340 | *) IFS=: | ||
| 341 | esac | ||
| 342 | set x $loginFullnameMailaddr | ||
| 343 | login=$2 | ||
| 344 | fullname=$3 | ||
| 345 | mailaddr=$4 | ||
| 346 | initialize_fullname="$initialize_fullname | ||
| 347 | fullname[\"$login\"] = \"$fullname\"" | ||
| 348 | initialize_mailaddr="$initialize_mailaddr | ||
| 349 | mailaddr[\"$login\"] = \"$mailaddr\"" | ||
| 350 | done | ||
| 351 | IFS=$oldIFS | ||
| 352 | esac | ||
| 353 | |||
| 354 | case $llogout in | ||
| 355 | ?*) sort -u -o $llogout <<EOF || exit | ||
| 356 | $logins | ||
| 357 | EOF | ||
| 358 | esac | ||
| 359 | output_authors='/^date: / { | ||
| 360 | if ($2 ~ /^[0-9]*[-\/][0-9][0-9][-\/][0-9][0-9]$/ && $3 ~ /^[0-9][0-9]:[0-9][0-9]:[0-9][0-9][-+0-9:]*;$/ && $4 == "author:" && $5 ~ /^[^;]*;$/) { | ||
| 361 | print substr($5, 1, length($5)-1) | ||
| 362 | } | ||
| 363 | }' | ||
| 364 | authors=` | ||
| 365 | $AWK "$output_authors" <$rlogout | | ||
| 366 | case $llogout in | ||
| 367 | '') sort -u;; | ||
| 368 | ?*) sort -u | comm -23 - $llogout | ||
| 369 | esac | ||
| 370 | ` | ||
| 371 | case $authors in | ||
| 372 | ?*) | ||
| 373 | cat >$llogout <<EOF || exit | ||
| 374 | $authors | ||
| 375 | EOF | ||
| 376 | initialize_author_script='s/["\\]/\\&/g; s/.*/author[\"&\"] = 1/' | ||
| 377 | initialize_author=`sed -e "$initialize_author_script" <$llogout` | ||
| 378 | awkscript=' | ||
| 379 | BEGIN { | ||
| 380 | alphabet = "abcdefghijklmnopqrstuvwxyz" | ||
| 381 | ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | ||
| 382 | '"$initialize_author"' | ||
| 383 | } | ||
| 384 | { | ||
| 385 | if (author[$1]) { | ||
| 386 | fullname = $5 | ||
| 387 | if (fullname ~ /[0-9]+-[^(]*\([0-9]+\)$/) { | ||
| 388 | # Remove the junk from fullnames like "0000-Admin(0000)". | ||
| 389 | fullname = substr(fullname, index(fullname, "-") + 1) | ||
| 390 | fullname = substr(fullname, 1, index(fullname, "(") - 1) | ||
| 391 | } | ||
| 392 | if (fullname ~ /,[^ ]/) { | ||
| 393 | # Some sites put comma-separated junk after the fullname. | ||
| 394 | # Remove it, but leave "Bill Gates, Jr" alone. | ||
| 395 | fullname = substr(fullname, 1, index(fullname, ",") - 1) | ||
| 396 | } | ||
| 397 | abbr = index(fullname, "&") | ||
| 398 | if (abbr) { | ||
| 399 | a = substr($1, 1, 1) | ||
| 400 | A = a | ||
| 401 | i = index(alphabet, a) | ||
| 402 | if (i) A = substr(ALPHABET, i, 1) | ||
| 403 | fullname = substr(fullname, 1, abbr-1) A substr($1, 2) substr(fullname, abbr+1) | ||
| 404 | } | ||
| 405 | |||
| 406 | # Quote quotes and backslashes properly in full names. | ||
| 407 | # Do not use gsub; traditional awk lacks it. | ||
| 408 | quoted = "" | ||
| 409 | rest = fullname | ||
| 410 | for (;;) { | ||
| 411 | p = index(rest, "\\") | ||
| 412 | q = index(rest, "\"") | ||
| 413 | if (p) { | ||
| 414 | if (q && q<p) p = q | ||
| 415 | } else { | ||
| 416 | if (!q) break | ||
| 417 | p = q | ||
| 418 | } | ||
| 419 | quoted = quoted substr(rest, 1, p-1) "\\" substr(rest, p, 1) | ||
| 420 | rest = substr(rest, p+1) | ||
| 421 | } | ||
| 422 | |||
| 423 | printf "fullname[\"%s\"] = \"%s%s\"\n", $1, quoted, rest | ||
| 424 | author[$1] = 0 | ||
| 425 | } | ||
| 426 | } | ||
| 427 | ' | ||
| 428 | |||
| 429 | initialize_fullname=` | ||
| 430 | { | ||
| 431 | (getent passwd $authors) || | ||
| 432 | ( | ||
| 433 | cat /etc/passwd | ||
| 434 | for author in $authors | ||
| 435 | do NIS_PATH= nismatch $author passwd.org_dir | ||
| 436 | done | ||
| 437 | ypmatch $authors passwd | ||
| 438 | ) | ||
| 439 | } 2>/dev/null | | ||
| 440 | $AWK -F: "$awkscript" | ||
| 441 | `$initialize_fullname | ||
| 442 | esac | ||
| 443 | |||
| 444 | |||
| 445 | # Function to print a single log line. | ||
| 446 | # We don't use awk functions, to stay compatible with old awk versions. | ||
| 447 | # `Log' is the log message (with \n replaced by \001). | ||
| 448 | # `files' contains the affected files. | ||
| 449 | printlogline='{ | ||
| 450 | |||
| 451 | # Following the GNU coding standards, rewrite | ||
| 452 | # * file: (function): comment | ||
| 453 | # to | ||
| 454 | # * file (function): comment | ||
| 455 | if (Log ~ /^\([^)]*\): /) { | ||
| 456 | i = index(Log, ")") | ||
| 457 | files = files " " substr(Log, 1, i) | ||
| 458 | Log = substr(Log, i+3) | ||
| 459 | } | ||
| 460 | |||
| 461 | # If "label: comment" is too long, break the line after the ":". | ||
| 462 | sep = " " | ||
| 463 | if ('"$length"' <= '"$indent"' + 1 + length(files) + index(Log, SOH)) sep = "\n" indent_string | ||
| 464 | |||
| 465 | # Print the label. | ||
| 466 | printf "%s*%s:", indent_string, files | ||
| 467 | |||
| 468 | # Print each line of the log, transliterating \001 to \n. | ||
| 469 | while ((i = index(Log, SOH)) != 0) { | ||
| 470 | logline = substr(Log, 1, i-1) | ||
| 471 | if (logline ~ /[^'"$tab"' ]/) { | ||
| 472 | printf "%s%s\n", sep, logline | ||
| 473 | } else { | ||
| 474 | print "" | ||
| 475 | } | ||
| 476 | sep = indent_string | ||
| 477 | Log = substr(Log, i+1) | ||
| 478 | } | ||
| 479 | }' | ||
| 480 | |||
| 481 | # Pattern to match the `revision' line of rlog output. | ||
| 482 | rlog_revision_pattern='^revision [0-9]+\.[0-9]+(\.[0-9]+\.[0-9]+)*(['"$tab"' ]+locked by: [^'"$tab"' $,.0-9:;@]*[^'"$tab"' $,:;@][^'"$tab"' $,.0-9:;@]*;)?['"$tab"' ]*$' | ||
| 483 | |||
| 484 | case $hostname in | ||
| 485 | '') | ||
| 486 | hostname=`( | ||
| 487 | hostname || uname -n || uuname -l || cat /etc/whoami | ||
| 488 | ) 2>/dev/null` || { | ||
| 489 | echo >&2 "$0: cannot deduce hostname" | ||
| 490 | exit 1 | ||
| 491 | } | ||
| 492 | |||
| 493 | case $hostname in | ||
| 494 | *.*) ;; | ||
| 495 | *) | ||
| 496 | domainname=`(domainname) 2>/dev/null` && | ||
| 497 | case $domainname in | ||
| 498 | *.*) hostname=$hostname.$domainname | ||
| 499 | esac | ||
| 500 | esac | ||
| 501 | esac | ||
| 502 | |||
| 503 | |||
| 504 | # Process the rlog output, generating ChangeLog style entries. | ||
| 505 | |||
| 506 | # First, reformat the rlog output so that each line contains one log entry. | ||
| 507 | # Transliterate \n to \001 so that multiline entries fit on a single line. | ||
| 508 | # Discard irrelevant rlog output. | ||
| 509 | $AWK <$rlogout ' | ||
| 510 | BEGIN { repository = "'"$repository"'" } | ||
| 511 | /^RCS file:/ { | ||
| 512 | if (repository != "") { | ||
| 513 | filename = $3 | ||
| 514 | if (substr(filename, 1, length(repository) + 1) == repository "/") { | ||
| 515 | filename = substr(filename, length(repository) + 2) | ||
| 516 | } | ||
| 517 | if (filename ~ /,v$/) { | ||
| 518 | filename = substr(filename, 1, length(filename) - 2) | ||
| 519 | } | ||
| 520 | if (filename ~ /(^|\/)Attic\/[^\/]*$/) { | ||
| 521 | i = length(filename) | ||
| 522 | while (substr(filename, i, 1) != "/") i-- | ||
| 523 | filename = substr(filename, 1, i - 6) substr(filename, i + 1) | ||
| 524 | } | ||
| 525 | } | ||
| 526 | rev = "?" | ||
| 527 | } | ||
| 528 | /^Working file:/ { if (repository == "") filename = $3 } | ||
| 529 | /'"$rlog_revision_pattern"'/, /^(-----------*|===========*)$/ { | ||
| 530 | line = $0 | ||
| 531 | if (line ~ /'"$rlog_revision_pattern"'/) { | ||
| 532 | rev = $2 | ||
| 533 | next | ||
| 534 | } | ||
| 535 | if (line ~ /^date: [0-9][- +\/0-9:]*;/) { | ||
| 536 | date = $2 | ||
| 537 | if (date ~ /\//) { | ||
| 538 | # This is a traditional RCS format date YYYY/MM/DD. | ||
| 539 | # Replace "/"s with "-"s to get ISO format. | ||
| 540 | newdate = "" | ||
| 541 | while ((i = index(date, "/")) != 0) { | ||
| 542 | newdate = newdate substr(date, 1, i-1) "-" | ||
| 543 | date = substr(date, i+1) | ||
| 544 | } | ||
| 545 | date = newdate date | ||
| 546 | } | ||
| 547 | time = substr($3, 1, length($3) - 1) | ||
| 548 | author = substr($5, 1, length($5)-1) | ||
| 549 | printf "%s %s %s %s %s %c", filename, rev, date, time, author, 1 | ||
| 550 | rev = "?" | ||
| 551 | next | ||
| 552 | } | ||
| 553 | if (line ~ /^branches: /) { next } | ||
| 554 | if (line ~ /^(-----------*|===========*)$/) { print ""; next } | ||
| 555 | if (line == "Initial revision" || line ~ /^file .+ was initially added on branch .+\.$/) { | ||
| 556 | line = "New file." | ||
| 557 | } | ||
| 558 | printf "%s%c", line, 1 | ||
| 559 | } | ||
| 560 | ' | | ||
| 561 | |||
| 562 | # Now each line is of the form | ||
| 563 | # FILENAME REVISION YYYY-MM-DD HH:MM:SS[+-TIMEZONE] AUTHOR \001LOG | ||
| 564 | # where \001 stands for a carriage return, | ||
| 565 | # and each line of the log is terminated by \001 instead of \n. | ||
| 566 | # Sort the log entries, first by date+time (in reverse order), | ||
| 567 | # then by author, then by log entry, and finally by file name and revision | ||
| 568 | # (just in case). | ||
| 569 | sort +2 -4r +4 +0 | | ||
| 570 | |||
| 571 | # Finally, reformat the sorted log entries. | ||
| 572 | $AWK ' | ||
| 573 | BEGIN { | ||
| 574 | logTZ = "'"$logTZ"'" | ||
| 575 | revision = "'"$revision"'" | ||
| 576 | |||
| 577 | # Some awk variants do not understand "\001", so we have to | ||
| 578 | # put the char directly in the file. | ||
| 579 | SOH="" # <-- There is a single SOH (octal code 001) here. | ||
| 580 | |||
| 581 | # Initialize the fullname and mailaddr associative arrays. | ||
| 582 | '"$initialize_fullname"' | ||
| 583 | '"$initialize_mailaddr"' | ||
| 584 | |||
| 585 | # Initialize indent string. | ||
| 586 | indent_string = "" | ||
| 587 | i = '"$indent"' | ||
| 588 | if (0 < '"$tabwidth"') | ||
| 589 | for (; '"$tabwidth"' <= i; i -= '"$tabwidth"') | ||
| 590 | indent_string = indent_string "\t" | ||
| 591 | while (1 <= i--) | ||
| 592 | indent_string = indent_string " " | ||
| 593 | } | ||
| 594 | |||
| 595 | { | ||
| 596 | newlog = substr($0, 1 + index($0, SOH)) | ||
| 597 | |||
| 598 | # Ignore log entries prefixed by "#". | ||
| 599 | if (newlog ~ /^#/) { next } | ||
| 600 | |||
| 601 | if (Log != newlog || date != $3 || author != $5) { | ||
| 602 | |||
| 603 | # The previous log and this log differ. | ||
| 604 | |||
| 605 | # Print the old log. | ||
| 606 | if (date != "") '"$printlogline"' | ||
| 607 | |||
| 608 | # Logs that begin with "{clumpname} " should be grouped together, | ||
| 609 | # and the clumpname should be removed. | ||
| 610 | # Extract the new clumpname from the log header, | ||
| 611 | # and use it to decide whether to output a blank line. | ||
| 612 | newclumpname = "" | ||
| 613 | sep = "\n" | ||
| 614 | if (date == "") sep = "" | ||
| 615 | if (newlog ~ /^\{[^'"$tab"' }]*}['"$tab"' ]/) { | ||
| 616 | i = index(newlog, "}") | ||
| 617 | newclumpname = substr(newlog, 1, i) | ||
| 618 | while (substr(newlog, i+1) ~ /^['"$tab"' ]/) i++ | ||
| 619 | newlog = substr(newlog, i+1) | ||
| 620 | if (clumpname == newclumpname) sep = "" | ||
| 621 | } | ||
| 622 | printf sep | ||
| 623 | clumpname = newclumpname | ||
| 624 | |||
| 625 | # Get ready for the next log. | ||
| 626 | Log = newlog | ||
| 627 | if (files != "") | ||
| 628 | for (i in filesknown) | ||
| 629 | filesknown[i] = 0 | ||
| 630 | files = "" | ||
| 631 | } | ||
| 632 | if (date != $3 || author != $5) { | ||
| 633 | # The previous date+author and this date+author differ. | ||
| 634 | # Print the new one. | ||
| 635 | date = $3 | ||
| 636 | time = $4 | ||
| 637 | author = $5 | ||
| 638 | |||
| 639 | zone = "" | ||
| 640 | if (logTZ && ((i = index(time, "-")) || (i = index(time, "+")))) | ||
| 641 | zone = " " substr(time, i) | ||
| 642 | |||
| 643 | # Print "date[ timezone] fullname <email address>". | ||
| 644 | # Get fullname and email address from associative arrays; | ||
| 645 | # default to author and author@hostname if not in arrays. | ||
| 646 | if (fullname[author]) | ||
| 647 | auth = fullname[author] | ||
| 648 | else | ||
| 649 | auth = author | ||
| 650 | printf "%s%s %s ", date, zone, auth | ||
| 651 | if (mailaddr[author]) | ||
| 652 | printf "<%s>\n\n", mailaddr[author] | ||
| 653 | else | ||
| 654 | printf "<%s@%s>\n\n", author, "'"$hostname"'" | ||
| 655 | } | ||
| 656 | if (! filesknown[$1]) { | ||
| 657 | filesknown[$1] = 1 | ||
| 658 | if (files == "") files = " " $1 | ||
| 659 | else files = files ", " $1 | ||
| 660 | if (revision && $2 != "?") files = files " " $2 | ||
| 661 | } | ||
| 662 | } | ||
| 663 | END { | ||
| 664 | # Print the last log. | ||
| 665 | if (date != "") { | ||
| 666 | '"$printlogline"' | ||
| 667 | printf "\n" | ||
| 668 | } | ||
| 669 | } | ||
| 670 | ' && | ||
| 671 | |||
| 672 | |||
| 673 | # Exit successfully. | ||
| 674 | |||
| 675 | exec rm -fr $logdir | ||
| 676 | |||
| 677 | # Local Variables: | ||
| 678 | # tab-width:4 | ||
| 679 | # End: | ||
diff --git a/lib-src/timer.c b/lib-src/timer.c deleted file mode 100644 index 9bd547ce8f2..00000000000 --- a/lib-src/timer.c +++ /dev/null | |||
| @@ -1,368 +0,0 @@ | |||
| 1 | /* timer.c --- daemon to provide a tagged interval timer service | ||
| 2 | |||
| 3 | This little daemon runs forever waiting for commands to schedule events. | ||
| 4 | SIGALRM causes | ||
| 5 | it to check its queue for events attached to the current second; if | ||
| 6 | one is found, its label is written to stdout. SIGTERM causes it to | ||
| 7 | terminate, printing a list of pending events. | ||
| 8 | |||
| 9 | This program is intended to be used with the lisp package called | ||
| 10 | timer.el. The first such program was written anonymously in 1990. | ||
| 11 | This version was documented and rewritten for portability by | ||
| 12 | esr@snark.thyrsus.com, Aug 7 1992. */ | ||
| 13 | |||
| 14 | #include <stdio.h> | ||
| 15 | #include <signal.h> | ||
| 16 | #include <errno.h> | ||
| 17 | #include <sys/types.h> /* time_t */ | ||
| 18 | |||
| 19 | #include <../src/config.h> | ||
| 20 | #undef read | ||
| 21 | |||
| 22 | #ifdef LINUX | ||
| 23 | /* Perhaps this is correct unconditionally. */ | ||
| 24 | #undef signal | ||
| 25 | #endif | ||
| 26 | #ifdef _CX_UX | ||
| 27 | /* I agree with the comment above, this probably should be unconditional (it | ||
| 28 | * is already unconditional in a couple of other files in this directory), | ||
| 29 | * but in the spirit of minimizing the effects of my port, I am making it | ||
| 30 | * conditional on _CX_UX. | ||
| 31 | */ | ||
| 32 | #undef signal | ||
| 33 | #endif | ||
| 34 | |||
| 35 | |||
| 36 | extern int errno; | ||
| 37 | extern char *strerror (); | ||
| 38 | extern time_t time (); | ||
| 39 | |||
| 40 | /* | ||
| 41 | * The field separator for input. This character shouldn't occur in dates, | ||
| 42 | * and should be printable so event strings are readable by people. | ||
| 43 | */ | ||
| 44 | #define FS '@' | ||
| 45 | |||
| 46 | struct event | ||
| 47 | { | ||
| 48 | char *token; | ||
| 49 | time_t reply_at; | ||
| 50 | }; | ||
| 51 | int events_size; /* How many slots have we allocated? */ | ||
| 52 | int num_events; /* How many are actually scheduled? */ | ||
| 53 | struct event *events; /* events[0 .. num_events-1] are the | ||
| 54 | valid events. */ | ||
| 55 | |||
| 56 | char *pname; /* program name for error messages */ | ||
| 57 | |||
| 58 | /* This buffer is used for reading commands. | ||
| 59 | We make it longer when necessary, but we never free it. */ | ||
| 60 | char *buf; | ||
| 61 | /* This is the allocated size of buf. */ | ||
| 62 | int buf_size; | ||
| 63 | |||
| 64 | /* Non-zero means don't handle an alarm now; | ||
| 65 | instead, just set alarm_deferred if an alarm happens. | ||
| 66 | We set this around parts of the program that call malloc and free. */ | ||
| 67 | int defer_alarms; | ||
| 68 | |||
| 69 | /* Non-zero if an alarm came in during the reading of a command. */ | ||
| 70 | int alarm_deferred; | ||
| 71 | |||
| 72 | /* Schedule one event, and arrange an alarm for it. | ||
| 73 | STR is a string of two fields separated by FS. | ||
| 74 | First field is string for get_date, saying when to wake-up. | ||
| 75 | Second field is a token to identify the request. */ | ||
| 76 | |||
| 77 | void | ||
| 78 | schedule (str) | ||
| 79 | char *str; | ||
| 80 | { | ||
| 81 | extern time_t get_date (); | ||
| 82 | extern char *strcpy (); | ||
| 83 | time_t now; | ||
| 84 | register char *p; | ||
| 85 | static struct event *ep; | ||
| 86 | |||
| 87 | /* check entry format */ | ||
| 88 | for (p = str; *p && *p != FS; p++) | ||
| 89 | continue; | ||
| 90 | if (!*p) | ||
| 91 | { | ||
| 92 | fprintf (stderr, "%s: bad input format: %s\n", pname, str); | ||
| 93 | return; | ||
| 94 | } | ||
| 95 | *p++ = 0; | ||
| 96 | |||
| 97 | /* allocate an event slot */ | ||
| 98 | ep = events + num_events; | ||
| 99 | |||
| 100 | /* If the event array is full, stretch it. After stretching, we know | ||
| 101 | that ep will be pointing to an available event spot. */ | ||
| 102 | if (ep == events + events_size) | ||
| 103 | { | ||
| 104 | int old_size = events_size; | ||
| 105 | |||
| 106 | events_size *= 2; | ||
| 107 | events = ((struct event *) | ||
| 108 | realloc (events, events_size * sizeof (struct event))); | ||
| 109 | if (! events) | ||
| 110 | { | ||
| 111 | fprintf (stderr, "%s: virtual memory exhausted.\n", pname); | ||
| 112 | /* Since there is so much virtual memory, and running out | ||
| 113 | almost surely means something is very very wrong, | ||
| 114 | it is best to exit rather than continue. */ | ||
| 115 | exit (1); | ||
| 116 | } | ||
| 117 | |||
| 118 | while (old_size < events_size) | ||
| 119 | events[old_size++].token = NULL; | ||
| 120 | } | ||
| 121 | |||
| 122 | /* Don't allow users to schedule events in past time. */ | ||
| 123 | ep->reply_at = get_date (str, NULL); | ||
| 124 | if (ep->reply_at - time (&now) < 0) | ||
| 125 | { | ||
| 126 | fprintf (stderr, "%s: bad time spec: %s%c%s\n", pname, str, FS, p); | ||
| 127 | return; | ||
| 128 | } | ||
| 129 | |||
| 130 | /* save the event description */ | ||
| 131 | ep->token = (char *) malloc ((unsigned) strlen (p) + 1); | ||
| 132 | if (! ep->token) | ||
| 133 | { | ||
| 134 | fprintf (stderr, "%s: malloc %s: %s%c%s\n", | ||
| 135 | pname, strerror (errno), str, FS, p); | ||
| 136 | return; | ||
| 137 | } | ||
| 138 | |||
| 139 | strcpy (ep->token, p); | ||
| 140 | num_events++; | ||
| 141 | } | ||
| 142 | |||
| 143 | /* Print the notification for the alarmed event just arrived if any, | ||
| 144 | and schedule an alarm for the next event if any. */ | ||
| 145 | |||
| 146 | void | ||
| 147 | notify () | ||
| 148 | { | ||
| 149 | time_t now, tdiff, waitfor = -1; | ||
| 150 | register struct event *ep; | ||
| 151 | |||
| 152 | /* Inhibit interference with alarms while changing global vars. */ | ||
| 153 | defer_alarms = 1; | ||
| 154 | alarm_deferred = 0; | ||
| 155 | |||
| 156 | now = time ((time_t *) NULL); | ||
| 157 | |||
| 158 | for (ep = events; ep < events + num_events; ep++) | ||
| 159 | /* Are any events ready to fire? */ | ||
| 160 | if (ep->reply_at <= now) | ||
| 161 | { | ||
| 162 | fputs (ep->token, stdout); | ||
| 163 | putc ('\n', stdout); | ||
| 164 | fflush (stdout); | ||
| 165 | free (ep->token); | ||
| 166 | |||
| 167 | /* We now have a hole in the event array; fill it with the last | ||
| 168 | event. */ | ||
| 169 | ep->token = events[num_events - 1].token; | ||
| 170 | ep->reply_at = events[num_events - 1].reply_at; | ||
| 171 | num_events--; | ||
| 172 | |||
| 173 | /* We ought to scan this event again. */ | ||
| 174 | ep--; | ||
| 175 | } | ||
| 176 | else | ||
| 177 | { | ||
| 178 | /* next timeout should be the soonest of any remaining */ | ||
| 179 | if ((tdiff = ep->reply_at - now) < waitfor || waitfor < 0) | ||
| 180 | waitfor = (long)tdiff; | ||
| 181 | } | ||
| 182 | |||
| 183 | /* If there are no more events, we needn't bother setting an alarm. */ | ||
| 184 | if (num_events > 0) | ||
| 185 | alarm (waitfor); | ||
| 186 | |||
| 187 | /* Now check if there was another alarm | ||
| 188 | while we were handling an explicit request. */ | ||
| 189 | defer_alarms = 0; | ||
| 190 | if (alarm_deferred) | ||
| 191 | notify (); | ||
| 192 | alarm_deferred = 0; | ||
| 193 | } | ||
| 194 | |||
| 195 | /* Read one command from command from standard input | ||
| 196 | and schedule the event for it. */ | ||
| 197 | |||
| 198 | void | ||
| 199 | getevent () | ||
| 200 | { | ||
| 201 | int i; | ||
| 202 | |||
| 203 | /* In principle the itimer should be disabled on entry to this | ||
| 204 | function, but it really doesn't make any important difference | ||
| 205 | if it isn't. */ | ||
| 206 | |||
| 207 | if (buf == 0) | ||
| 208 | { | ||
| 209 | buf_size = 80; | ||
| 210 | buf = (char *) malloc (buf_size); | ||
| 211 | } | ||
| 212 | |||
| 213 | /* Read a line from standard input, expanding buf if it is too short | ||
| 214 | to hold the line. */ | ||
| 215 | for (i = 0; ; i++) | ||
| 216 | { | ||
| 217 | char c; | ||
| 218 | int nread; | ||
| 219 | |||
| 220 | if (i >= buf_size) | ||
| 221 | { | ||
| 222 | buf_size *= 2; | ||
| 223 | alarm_deferred = 0; | ||
| 224 | defer_alarms = 1; | ||
| 225 | buf = (char *) realloc (buf, buf_size); | ||
| 226 | defer_alarms = 0; | ||
| 227 | if (alarm_deferred) | ||
| 228 | notify (); | ||
| 229 | alarm_deferred = 0; | ||
| 230 | } | ||
| 231 | |||
| 232 | /* Read one character into c. */ | ||
| 233 | while (1) | ||
| 234 | { | ||
| 235 | nread = read (fileno (stdin), &c, 1); | ||
| 236 | |||
| 237 | /* Retry after transient error. */ | ||
| 238 | if (nread < 0 | ||
| 239 | && (1 | ||
| 240 | #ifdef EINTR | ||
| 241 | || errno == EINTR | ||
| 242 | #endif | ||
| 243 | #ifdef EAGAIN | ||
| 244 | || errno == EAGAIN | ||
| 245 | #endif | ||
| 246 | )) | ||
| 247 | continue; | ||
| 248 | |||
| 249 | /* Report serious errors. */ | ||
| 250 | if (nread < 0) | ||
| 251 | { | ||
| 252 | perror ("read"); | ||
| 253 | exit (1); | ||
| 254 | } | ||
| 255 | |||
| 256 | /* On eof, exit. */ | ||
| 257 | if (nread == 0) | ||
| 258 | exit (0); | ||
| 259 | |||
| 260 | break; | ||
| 261 | } | ||
| 262 | |||
| 263 | if (c == '\n') | ||
| 264 | { | ||
| 265 | buf[i] = '\0'; | ||
| 266 | break; | ||
| 267 | } | ||
| 268 | |||
| 269 | buf[i] = c; | ||
| 270 | } | ||
| 271 | |||
| 272 | /* Register the event. */ | ||
| 273 | alarm_deferred = 0; | ||
| 274 | defer_alarms = 1; | ||
| 275 | schedule (buf); | ||
| 276 | defer_alarms = 0; | ||
| 277 | notify (); | ||
| 278 | alarm_deferred = 0; | ||
| 279 | } | ||
| 280 | |||
| 281 | /* Handle incoming signal SIG. */ | ||
| 282 | |||
| 283 | SIGTYPE | ||
| 284 | sigcatch (sig) | ||
| 285 | int sig; | ||
| 286 | { | ||
| 287 | struct event *ep; | ||
| 288 | |||
| 289 | /* required on older UNIXes; harmless on newer ones */ | ||
| 290 | signal (sig, sigcatch); | ||
| 291 | |||
| 292 | switch (sig) | ||
| 293 | { | ||
| 294 | case SIGALRM: | ||
| 295 | if (defer_alarms) | ||
| 296 | alarm_deferred = 1; | ||
| 297 | else | ||
| 298 | notify (); | ||
| 299 | break; | ||
| 300 | case SIGTERM: | ||
| 301 | fprintf (stderr, "Events still queued:\n"); | ||
| 302 | for (ep = events; ep < events + num_events; ep++) | ||
| 303 | fprintf (stderr, "%d = %ld @ %s\n", | ||
| 304 | ep - events, ep->reply_at, ep->token); | ||
| 305 | exit (0); | ||
| 306 | break; | ||
| 307 | } | ||
| 308 | } | ||
| 309 | |||
| 310 | /*ARGSUSED*/ | ||
| 311 | int | ||
| 312 | main (argc, argv) | ||
| 313 | int argc; | ||
| 314 | char **argv; | ||
| 315 | { | ||
| 316 | for (pname = argv[0] + strlen (argv[0]); | ||
| 317 | *pname != '/' && pname != argv[0]; | ||
| 318 | pname--); | ||
| 319 | if (*pname == '/') | ||
| 320 | pname++; | ||
| 321 | |||
| 322 | events_size = 16; | ||
| 323 | events = ((struct event *) malloc (events_size * sizeof (*events))); | ||
| 324 | num_events = 0; | ||
| 325 | |||
| 326 | signal (SIGALRM, sigcatch); | ||
| 327 | signal (SIGTERM, sigcatch); | ||
| 328 | |||
| 329 | /* Loop reading commands from standard input | ||
| 330 | and scheduling alarms accordingly. | ||
| 331 | The alarms are handled asynchronously, while we wait for commands. */ | ||
| 332 | while (1) | ||
| 333 | getevent (); | ||
| 334 | } | ||
| 335 | |||
| 336 | #ifndef HAVE_STRERROR | ||
| 337 | char * | ||
| 338 | strerror (errnum) | ||
| 339 | int errnum; | ||
| 340 | { | ||
| 341 | extern char *sys_errlist[]; | ||
| 342 | extern int sys_nerr; | ||
| 343 | |||
| 344 | if (errnum >= 0 && errnum < sys_nerr) | ||
| 345 | return sys_errlist[errnum]; | ||
| 346 | return (char *) "Unknown error"; | ||
| 347 | } | ||
| 348 | |||
| 349 | #endif /* ! HAVE_STRERROR */ | ||
| 350 | |||
| 351 | long * | ||
| 352 | xmalloc (size) | ||
| 353 | int size; | ||
| 354 | { | ||
| 355 | register long *val; | ||
| 356 | |||
| 357 | val = (long *) malloc (size); | ||
| 358 | |||
| 359 | if (!val && size) | ||
| 360 | { | ||
| 361 | fprintf (stderr, "timer: virtual memory exceeded\n"); | ||
| 362 | exit (1); | ||
| 363 | } | ||
| 364 | |||
| 365 | return val; | ||
| 366 | } | ||
| 367 | |||
| 368 | /* timer.c ends here */ | ||
diff --git a/lib-src/wakeup.c b/lib-src/wakeup.c deleted file mode 100644 index 389519ba1f7..00000000000 --- a/lib-src/wakeup.c +++ /dev/null | |||
| @@ -1,53 +0,0 @@ | |||
| 1 | /* Program to produce output at regular intervals. */ | ||
| 2 | |||
| 3 | #ifdef HAVE_CONFIG_H | ||
| 4 | #include <config.h> | ||
| 5 | #endif | ||
| 6 | |||
| 7 | #include <stdio.h> | ||
| 8 | #include <sys/types.h> | ||
| 9 | |||
| 10 | #ifdef TIME_WITH_SYS_TIME | ||
| 11 | #include <sys/time.h> | ||
| 12 | #include <time.h> | ||
| 13 | #else | ||
| 14 | #ifdef HAVE_SYS_TIME_H | ||
| 15 | #include <sys/time.h> | ||
| 16 | #else | ||
| 17 | #include <time.h> | ||
| 18 | #endif | ||
| 19 | #endif | ||
| 20 | |||
| 21 | struct tm *localtime (); | ||
| 22 | |||
| 23 | void | ||
| 24 | main (argc, argv) | ||
| 25 | int argc; | ||
| 26 | char **argv; | ||
| 27 | { | ||
| 28 | int period = 60; | ||
| 29 | time_t when; | ||
| 30 | struct tm *tp; | ||
| 31 | |||
| 32 | if (argc > 1) | ||
| 33 | period = atoi (argv[1]); | ||
| 34 | |||
| 35 | while (1) | ||
| 36 | { | ||
| 37 | /* Make sure wakeup stops when Emacs goes away. */ | ||
| 38 | if (getppid () == 1) | ||
| 39 | exit (0); | ||
| 40 | printf ("Wake up!\n"); | ||
| 41 | fflush (stdout); | ||
| 42 | /* If using a period of 60, produce the output when the minute | ||
| 43 | changes. */ | ||
| 44 | if (period == 60) | ||
| 45 | { | ||
| 46 | time (&when); | ||
| 47 | tp = localtime (&when); | ||
| 48 | sleep (60 - tp->tm_sec); | ||
| 49 | } | ||
| 50 | else | ||
| 51 | sleep (period); | ||
| 52 | } | ||
| 53 | } | ||