X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=ident.c;h=7e917f74de234fd827658805537bc268c34adca6;hb=96768e3108f76a20699b23f7a1218949144b2394;hp=8da5609cb686432c04cb9ebc1e0bbda273c2b90a;hpb=d289d13625ffa568c3007c3620eaafeb521ac06d;p=git.git diff --git a/ident.c b/ident.c index 8da5609c..7e917f74 100644 --- a/ident.c +++ b/ident.c @@ -26,22 +26,23 @@ 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); +#ifndef NO_GETDOMAINNAME if (!strchr(real_email+len, '.')) { len = strlen(real_email); real_email[len++] = '.'; getdomainname(real_email+len, sizeof(real_email)-len); } - +#endif /* And set the default date */ datestamp(real_date, sizeof(real_date)); return 0; @@ -58,14 +59,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]; }