X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=ident.c;h=0fe81f6900dcb6951539c050f1398b1d4b208ea6;hb=78938b0d8a95b09d94af214fdb6b5f053a5edb98;hp=8da5609cb686432c04cb9ebc1e0bbda273c2b90a;hpb=d289d13625ffa568c3007c3620eaafeb521ac06d;p=git.git diff --git a/ident.c b/ident.c index 8da5609c..0fe81f69 100644 --- a/ident.c +++ b/ident.c @@ -26,13 +26,13 @@ int setup_ident(void) /* Get the name ("gecos") */ len = strlen(pw->pw_gecos); if (len >= sizeof(real_name)) - die("Your parents must have hated you"); + die("Your parents must have hated you!"); memcpy(real_name, pw->pw_gecos, len+1); /* Make up a fake email address (name + '@' + hostname [+ '.' + domainname]) */ len = strlen(pw->pw_name); if (len > sizeof(real_email)/2) - die("Your parents must have hated you"); + die("Your sysadmin must hate you!"); memcpy(real_email, pw->pw_name, len); real_email[len++] = '@'; gethostname(real_email + len, sizeof(real_email) - len); @@ -58,14 +58,24 @@ static int add_raw(char *buf, int size, int offset, const char *str) static int crud(unsigned char c) { - static const char crud_array[256] = { - [0 ... 31] = 1, - [' '] = 1, - ['.'] = 1, [','] = 1, - [':'] = 1, [';'] = 1, - ['<'] = 1, ['>'] = 1, - ['"'] = 1, ['\''] = 1, - }; + static char crud_array[256]; + static int crud_array_initialized = 0; + + if (!crud_array_initialized) { + int k; + + for (k = 0; k <= 31; ++k) crud_array[k] = 1; + crud_array[' '] = 1; + crud_array['.'] = 1; + crud_array[','] = 1; + crud_array[':'] = 1; + crud_array[';'] = 1; + crud_array['<'] = 1; + crud_array['>'] = 1; + crud_array['"'] = 1; + crud_array['\''] = 1; + crud_array_initialized = 1; + } return crud_array[c]; }