From: markus schnalke Date: Fri, 9 Dec 2011 17:44:19 +0000 (+0100) Subject: We have `NULL' in order to not need to write `(char *)0' anymore. X-Git-Tag: mmh-thesis-end~460 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=7e3bc577e84e13a47005a706718bd6ec0e6a0e0a;p=mmh We have `NULL' in order to not need to write `(char *)0' anymore. --- diff --git a/configure.ac b/configure.ac index 2fba897..35d1b2d 100644 --- a/configure.ac +++ b/configure.ac @@ -602,7 +602,7 @@ main() { char buf[4096]; int r1 = tgetent(buf, "vt100"); - int r2 = tgetent((char*)0,"vt100"); + int r2 = tgetent(NULL,"vt100"); if (r1 >= 0 && r1 == r2) { char tbuf[1024], *u; u = tbuf; diff --git a/sbr/context_read.c b/sbr/context_read.c index 57653ea..6ca9a3d 100644 --- a/sbr/context_read.c +++ b/sbr/context_read.c @@ -47,7 +47,7 @@ context_read(void) ** Find user's home directory. Try the HOME environment variable first, ** the home directory field in the password file if that's not found. */ - if ((mypath = getenv("HOME")) == (char *)0) { + if ((mypath = getenv("HOME")) == NULL) { if ((pw = getpwuid(getuid())) == (struct passwd *)0 || *pw->pw_dir == '\0') adios(NULL, "cannot determine your home directory"); @@ -67,15 +67,15 @@ context_read(void) defpath = getcpy(expanddir(cp)); if (stat(defpath, &st) != -1 && (st.st_mode & S_IFREG) == 0) - adios((char *)0, "`%s' specified by your MH environment variable is not a normal file", cp); + adios(NULL, "`%s' specified by your MH environment variable is not a normal file", cp); if ((ib = fopen(defpath, "r")) == (FILE *)0) - adios((char *)0, "unable to read the `%s' profile specified by your MH environment variable", defpath); + adios(NULL, "unable to read the `%s' profile specified by your MH environment variable", defpath); } else { defpath = concat(mypath, "/", mh_profile, NULL); if ((ib = fopen(defpath, "r")) == (FILE *)0) - adios((char *)0, "Doesn't look like nmh is installed. Run install-mh to do so."); + adios(NULL, "Doesn't look like nmh is installed. Run install-mh to do so."); cp = mh_profile; } @@ -89,7 +89,7 @@ context_read(void) ** one rooted in the home directory. */ - if ((cp = context_find("path")) == (char *)0) + if ((cp = context_find("path")) == NULL) adios(NULL, "Your %s file does not contain a path entry.", defpath); @@ -112,7 +112,7 @@ context_read(void) if (!makedir(nd)) adios(NULL, "unable to create %s", nd); } else if ((st.st_mode & S_IFDIR) == 0) - adios((char *)0, "`%s' is not a directory", nd); + adios(NULL, "`%s' is not a directory", nd); /* ** Open and read user's context file. The name of the context @@ -120,7 +120,7 @@ context_read(void) ** environment variable. */ - if ((cp = getenv("MHCONTEXT")) == (char *)0 || *cp == '\0') + if ((cp = getenv("MHCONTEXT")) == NULL || *cp == '\0') cp = context; /* diff --git a/sbr/ext_hook.c b/sbr/ext_hook.c index a4b0934..467718b 100644 --- a/sbr/ext_hook.c +++ b/sbr/ext_hook.c @@ -19,7 +19,7 @@ ext_hook(char *hook_name, char *message_file_name_1, char *message_file_name_2) static int did_message = 0; /* set if we've already output a message */ - if ((hook = context_find(hook_name)) == (char *)0) + if ((hook = context_find(hook_name)) == NULL) return (OK); switch (pid = vfork()) { @@ -32,7 +32,7 @@ ext_hook(char *hook_name, char *message_file_name_1, char *message_file_name_2) vec[0] = mhbasename(hook); vec[1] = message_file_name_1; vec[2] = message_file_name_2; - vec[3] = (char *)0; + vec[3] = NULL; execvp(hook, vec); _exit(-1); /* NOTREACHED */ @@ -44,7 +44,7 @@ ext_hook(char *hook_name, char *message_file_name_1, char *message_file_name_2) if (status != OK) { if (did_message == 0) { - if ((hook = context_find("msg-hook")) != (char *)0) + if ((hook = context_find("msg-hook")) != NULL) advise(NULL, hook); else advise(NULL, "external hook (%s) did not work properly.", hook); diff --git a/sbr/folder_addmsg.c b/sbr/folder_addmsg.c index 391f5c8..7a4a982 100644 --- a/sbr/folder_addmsg.c +++ b/sbr/folder_addmsg.c @@ -136,7 +136,7 @@ folder_addmsg(struct msgs **mpp, char *msgfile, int selected, from_dir, msgfile); ext_hook("ref-hook", oldmsg, newmsg); } else - ext_hook("add-hook", newmsg, (char *)0); + ext_hook("add-hook", newmsg, NULL); return msgnum; } else { @@ -195,7 +195,7 @@ folder_addmsg(struct msgs **mpp, char *msgfile, int selected, msgfile); ext_hook("ref-hook", oldmsg, newmsg); } else - ext_hook("add-hook", newmsg, (char *)0); + ext_hook("add-hook", newmsg, NULL); return msgnum; } diff --git a/sbr/folder_delmsgs.c b/sbr/folder_delmsgs.c index e9257bd..4950330 100644 --- a/sbr/folder_delmsgs.c +++ b/sbr/folder_delmsgs.c @@ -94,7 +94,7 @@ folder_delmsgs(struct msgs *mp, int unlink_msgs, int nohook) if (!nohook) { snprintf(msgpath, sizeof (msgpath), "%s/%d", mp->foldpath, msgnum); - ext_hook("del-hook", msgpath, (char *)0); + ext_hook("del-hook", msgpath, NULL); } dp = m_name(msgnum); diff --git a/uip/annosbr.c b/uip/annosbr.c index 034aa12..212d35c 100644 --- a/uip/annosbr.c +++ b/uip/annosbr.c @@ -135,7 +135,7 @@ annolist(char *file, char *comp, char *text, int number) if (number) printf("%d\t", ++count); - if (text == (char *)0 && (sp = strrchr(cp, '/')) != (char *)0) + if (text == NULL && (sp = strrchr(cp, '/')) != NULL) cp = sp + 1; printf("%s\n", cp); @@ -297,7 +297,7 @@ annosbr(int fd, char *file, char *comp, char *text, int inplace, if (strncasecmp(field, comp, length) == 0 && field[length] == ':') { if (delete == 0) { - if (text == (char *)0) + if (text == NULL) break; for (cp = field + length + 1; *cp == ' ' || *cp == '\t'; cp++) @@ -308,7 +308,7 @@ annosbr(int fd, char *file, char *comp, char *text, int inplace, break; } else { - if ((sp = strrchr(cp, '/')) != (char *)0) + if ((sp = strrchr(cp, '/')) != NULL) cp = sp + 1; if (strcmp(cp, text) == 0) diff --git a/uip/burst.c b/uip/burst.c index fc2f711..0e7c53a 100644 --- a/uip/burst.c +++ b/uip/burst.c @@ -364,13 +364,13 @@ burst(struct msgs **mpp, int msgnum, struct smsg *smsgs, int numburst, admonish(f3, "unable to rename %s to", f1); snprintf(f3, sizeof (f3), "%s/%d", maildir, i); - ext_hook("del-hook", f3, (char *)0); + ext_hook("del-hook", f3, NULL); } if (rename(f2, f1) == NOTOK) admonish(f1, "unable to rename %s to", f2); snprintf(f3, sizeof (f3), "%s/%d", maildir, i); - ext_hook("add-hook", f3, (char *)0); + ext_hook("add-hook", f3, NULL); copy_msg_flags(mp, i, msgnum); mp->msgflags |= SEQMOD; diff --git a/uip/inc.c b/uip/inc.c index 1834c92..f712152 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -295,7 +295,7 @@ main(int argc, char **argv) if (stat(newmail, &s1) == NOTOK || s1.st_size == 0) adios(NULL, "no mail to incorporate"); - if ((cp = strdup(newmail)) == (char *)0) + if ((cp = strdup(newmail)) == NULL) adios(NULL, "error allocating memory to copy newmail"); newmail = cp; @@ -304,7 +304,7 @@ main(int argc, char **argv) folder = getdeffol(); maildir = toabsdir(folder); - if ((maildir_copy = strdup(maildir)) == (char *)0) + if ((maildir_copy = strdup(maildir)) == NULL) adios(maildir, "error allocating memory to copy maildir"); if (!folder_exists(maildir)) { @@ -432,7 +432,7 @@ main(int argc, char **argv) snprintf(b, sizeof (b), "%s/%d", maildir_copy, msgnum + 1); - ext_hook("add-hook", b, (char *)0); + ext_hook("add-hook", b, NULL); if (aud) fputs(scanl, aud); diff --git a/uip/install-mh.c b/uip/install-mh.c index 615ac71..d5c16d9 100644 --- a/uip/install-mh.c +++ b/uip/install-mh.c @@ -85,7 +85,7 @@ main(int argc, char **argv) ** if that's not found. */ - if ((mypath = getenv("HOME")) == (char *)0) { + if ((mypath = getenv("HOME")) == NULL) { if ((pw = getpwuid(getuid())) == (struct passwd *)0 || *pw->pw_dir == '\0') adios(NULL, "cannot determine your home directory"); diff --git a/uip/mhstoresbr.c b/uip/mhstoresbr.c index 44fd19a..14963b5 100644 --- a/uip/mhstoresbr.c +++ b/uip/mhstoresbr.c @@ -867,7 +867,7 @@ output_content_folder(char *folder, char *filename) /* Read the folder. */ if ((mp = folder_read(folder))) { /* Link file into folder */ - msgnum = folder_addmsg(&mp, filename, 0, 0, 0, 0, (char *)0); + msgnum = folder_addmsg(&mp, filename, 0, 0, 0, 0, NULL); } else { advise(NULL, "unable to read folder %s", folder); return NOTOK; diff --git a/uip/rcvstore.c b/uip/rcvstore.c index 99ec48c..b934220 100644 --- a/uip/rcvstore.c +++ b/uip/rcvstore.c @@ -202,8 +202,8 @@ main(int argc, char **argv) ** Link message into folder, and possibly add ** to the Unseen-Sequence's. */ - if ((msgnum = folder_addmsg(&mp, tmpfilenam, 0, unseensw, 0, 0, - (char *)0)) == -1) + if ((msgnum = folder_addmsg(&mp, tmpfilenam, 0, unseensw, 0, 0, NULL)) + == -1) done(1); /* diff --git a/uip/rmf.c b/uip/rmf.c index 10a4a10..36c1eed 100644 --- a/uip/rmf.c +++ b/uip/rmf.c @@ -158,7 +158,7 @@ rmf(char *folder) ** Run the external delete hook program. */ - ext_hook("del-hook", maildir, (char *)0); + ext_hook("del-hook", maildir, NULL); j = strlen(backup_prefix); while ((dp = readdir(dd))) { diff --git a/uip/send.c b/uip/send.c index a9ae46d..051e357 100644 --- a/uip/send.c +++ b/uip/send.c @@ -109,7 +109,7 @@ main(int argc, char **argv) char *msgs[MAXARGS], *vec[MAXARGS]; struct msgs *mp; struct stat st; - char *attach = (char *)0; /* header field name for attachments */ + char *attach = NULL; /* header field name for attachments */ int attachformat = 0; /* mhbuild format specifier for attachments */ #ifdef UCI FILE *fp; diff --git a/uip/sendsbr.c b/uip/sendsbr.c index 8d85559..1534402 100644 --- a/uip/sendsbr.c +++ b/uip/sendsbr.c @@ -103,7 +103,7 @@ sendsbr(char **vec, int vecp, char *drft, struct stat *st, ** and modified if desired. */ - if (attachment_header_field_name != (char *)0) { + if (attachment_header_field_name != NULL) { switch (attach(attachment_header_field_name, drft, attachformat)) { case OK: @@ -167,7 +167,7 @@ sendsbr(char **vec, int vecp, char *drft, struct stat *st, if (strlen(composition_file_name) >= sizeof (composition_file_name) - 6) - advise((char *)0, "unable to remove original composition file."); + advise(NULL, "unable to remove original composition file."); else { if ((p = strrchr(composition_file_name, '/')) == NULL) @@ -203,7 +203,7 @@ attach(char *attachment_header_field_name, char *draft_file_name, */ if ((draft_file = fopen(draft_file_name, "r")) == (FILE *)0) - adios((char *)0, "can't open draft file `%s'.", + adios(NULL, "can't open draft file `%s'.", draft_file_name); /* @@ -272,7 +272,7 @@ attach(char *attachment_header_field_name, char *draft_file_name, if ((has_body && body_file == (FILE *)0) || composition_file == (FILE *)0) { clean_up_temporary_files(); - adios((char *)0, "unable to open all of the temporary files."); + adios(NULL, "unable to open all of the temporary files."); } /* @@ -400,7 +400,7 @@ make_mime_composition_file_entry(char *file_name, int attachformat) char *p; /* miscellaneous string pointer */ struct stat st; /* file status buffer */ - content_type = (char *)0; + content_type = NULL; /* ** Check the file name for a suffix. Scan the context for that @@ -411,7 +411,7 @@ make_mime_composition_file_entry(char *file_name, int attachformat) ** the field, including the dot. */ - if ((p = strrchr(file_name, '.')) != (char *)0) { + if ((p = strrchr(file_name, '.')) != NULL) { for (np = m_defs; np; np = np->n_next) { if (strncasecmp(np->n_name, "mhshow-suffix-", 14) == 0 && mh_strcasecmp(p, np->n_field) == 0) @@ -429,10 +429,10 @@ make_mime_composition_file_entry(char *file_name, int attachformat) ** content type based on this check. */ - if (content_type == (char *)0) { + if (content_type == NULL) { if ((fp = fopen(file_name, "r")) == (FILE *)0) { clean_up_temporary_files(); - adios((char *)0, "unable to access file \"%s\"", + adios(NULL, "unable to access file \"%s\"", file_name); } @@ -461,7 +461,7 @@ make_mime_composition_file_entry(char *file_name, int attachformat) if (stat(file_name, &st) == -1 || access(file_name, R_OK) != 0) { clean_up_temporary_files(); - adios((char *)0, "unable to access file \"%s\"", file_name); + adios(NULL, "unable to access file \"%s\"", file_name); } switch (attachformat) { @@ -470,19 +470,19 @@ make_mime_composition_file_entry(char *file_name, int attachformat) fprintf(composition_file, "#%s; name=\"%s\"; x-unix-mode=0%.3ho", content_type, ((p = strrchr(file_name, '/')) - == (char *)0) ? file_name : p + 1, + == NULL) ? file_name : p + 1, (unsigned short)(st.st_mode & 0777)); if (strlen(file_name) > MAXPATHLEN) { clean_up_temporary_files(); - adios((char *)0, "attachment file name `%s' too long.", + adios(NULL, "attachment file name `%s' too long.", file_name); } sprintf(cmd, "file '%s'", file_name); if ((fp = popen(cmd, "r")) != (FILE *)0 && - fgets(cmd, sizeof (cmd), fp) != (char *)0) { + fgets(cmd, sizeof (cmd), fp) != NULL) { *strchr(cmd, '\n') = '\0'; /* @@ -528,7 +528,7 @@ make_mime_composition_file_entry(char *file_name, int attachformat) fprintf(composition_file, "#%s; name=\"%s\" <>{attachment}", content_type, - ((p = strrchr(file_name, '/')) == (char *)0) ? + ((p = strrchr(file_name, '/')) == NULL) ? file_name : p + 1); } @@ -550,13 +550,13 @@ make_mime_composition_file_entry(char *file_name, int attachformat) fprintf(composition_file, "#%s; name=\"%s\" <>{attachment; modification-date=\"%s\"}", content_type, - ((p = strrchr(file_name, '/')) == (char *)0) ? + ((p = strrchr(file_name, '/')) == NULL) ? file_name : p + 1, dtime(&st.st_mtime, 0)); } break; default: - adios((char *)0, "unsupported attachformat %d", attachformat); + adios(NULL, "unsupported attachformat %d", attachformat); } /* diff --git a/uip/sortm.c b/uip/sortm.c index 0d8e39d..59247c2 100644 --- a/uip/sortm.c +++ b/uip/sortm.c @@ -43,7 +43,7 @@ struct smsg { static struct smsg *smsgs; int nmsgs; -char *subjsort = (char *) 0; /* sort on subject if != 0 */ +char *subjsort = NULL; /* sort on subject if != 0 */ unsigned long datelimit = 0; int submajor = 0; /* if true, sort on subject-major */ int verbose; @@ -126,7 +126,7 @@ main(int argc, char **argv) subjsort = "subject"; continue; case NSUBJSW: - subjsort = (char *)0; + subjsort = NULL; continue; case LIMSW: diff --git a/uip/viamail.c b/uip/viamail.c index 3fff44a..007adb3 100644 --- a/uip/viamail.c +++ b/uip/viamail.c @@ -222,7 +222,7 @@ via_mail(char *mailsw, char *subjsw, char *parmsw, char *descsw, if (verbsw) vec[vecp++] = "-verbose"; - switch (sendsbr(vec, vecp, tmpfil, &st, 0, (char *)0, 0)) { + switch (sendsbr(vec, vecp, tmpfil, &st, 0, NULL, 0)) { case DONE: case NOTOK: status++; diff --git a/uip/whatnowsbr.c b/uip/whatnowsbr.c index 032566e..aefe67f 100644 --- a/uip/whatnowsbr.c +++ b/uip/whatnowsbr.c @@ -128,7 +128,7 @@ WhatNow(int argc, char **argv) char buf[BUFSIZ], prompt[BUFSIZ]; char **argp, **arguments; struct stat st; - char *attach = (char *)0; /* attachment header field name */ + char *attach = NULL; /* attachment header field name */ char cwd[MAXPATHLEN + 1]; /* current working directory */ char file[MAXPATHLEN + 1]; /* file name buffer */ char shell[MAXPATHLEN + 1]; /* shell response buffer */ @@ -148,7 +148,7 @@ WhatNow(int argc, char **argv) ** Get the initial current working directory. */ - if (getcwd(cwd, sizeof (cwd)) == (char *)0) { + if (getcwd(cwd, sizeof (cwd)) == NULL) { adios("getcwd", "could not get working directory"); } @@ -188,7 +188,7 @@ WhatNow(int argc, char **argv) continue; case ATTACHSW: - if (attach != (char *)0) + if (attach != NULL) adios(NULL, "only one attachment header field name at a time!"); if (!(attach = *argp++) || *attach == '-') adios(NULL, "missing argument to %s", @@ -300,7 +300,7 @@ WhatNow(int argc, char **argv) ** the absolute path. */ - if (*(argp+1) == (char *)0) { + if (*(argp+1) == NULL) { sprintf(buf, "$SHELL -c \"cd;pwd\""); } else { writesomecmd(buf, BUFSIZ, "cd", "pwd", argp); @@ -308,7 +308,7 @@ WhatNow(int argc, char **argv) if ((f = popen_in_dir(cwd, buf, "r")) != (FILE *)0) { fgets(cwd, sizeof (cwd), f); - if (strchr(cwd, '\n') != (char *)0) + if (strchr(cwd, '\n') != NULL) *strchr(cwd, '\n') = '\0'; pclose(f); @@ -344,15 +344,15 @@ WhatNow(int argc, char **argv) ** -n numbers listing */ - if (attach == (char *)0) { - advise((char *)0, "can't list because no header field name was given."); + if (attach == NULL) { + advise(NULL, "can't list because no header field name was given."); break; } - l = (char *)0; + l = NULL; n = 0; - while (*++argp != (char *)0) { + while (*++argp != NULL) { if (strcmp(*argp, "-l") == 0) l = "/"; @@ -370,7 +370,7 @@ WhatNow(int argc, char **argv) } if (n == -1) - advise((char *)0, "usage is alist [-ln]."); + advise(NULL, "usage is alist [-ln]."); else annolist(drft, attach, l, n); @@ -382,13 +382,13 @@ WhatNow(int argc, char **argv) ** Attach files to current draft. */ - if (attach == (char *)0) { - advise((char *)0, "can't attach because no header field name was given."); + if (attach == NULL) { + advise(NULL, "can't attach because no header field name was given."); break; } - if (*(argp+1) == (char *)0) { - advise((char *)0, "attach command requires file argument(s)."); + if (*(argp+1) == NULL) { + advise(NULL, "attach command requires file argument(s)."); break; } @@ -412,7 +412,7 @@ WhatNow(int argc, char **argv) if ((f = popen_in_dir(cwd, buf, "r")) != (FILE *)0) { while (fgets(shell, sizeof (shell), f) - != (char *)0) { + != NULL) { *(strchr(shell, '\n')) = '\0'; if (*shell == '/') @@ -438,8 +438,8 @@ WhatNow(int argc, char **argv) ** Detach files from current draft. */ - if (attach == (char *)0) { - advise((char *)0, "can't detach because no header field name was given."); + if (attach == NULL) { + advise(NULL, "can't detach because no header field name was given."); break; } @@ -450,7 +450,7 @@ WhatNow(int argc, char **argv) */ for (n = 0, arguments = argp + 1; - *arguments != (char *)0; + *arguments != NULL; arguments++) { if (strcmp(*arguments, "-n") == 0) { n = 1; @@ -468,7 +468,7 @@ WhatNow(int argc, char **argv) if (n == 1) { for (arguments = argp + 1; - *arguments != (char *)0; + *arguments != NULL; arguments++) { if (strcmp(*arguments, "-n") == 0) continue; @@ -478,7 +478,7 @@ WhatNow(int argc, char **argv) annotate(drft, attach, NULL, 1, 0, n, 1); - for (argp = arguments + 1; *argp != (char *)0; argp++) { + for (argp = arguments + 1; *argp != NULL; argp++) { if (atoi(*argp) > n) { if (atoi(*argp) == 1) *argp = ""; @@ -555,15 +555,15 @@ writesomecmd(char *buf, int bufsz, char *cmd, char *trailcmd, char **argp) */ int trailln = strlen(trailcmd) + 3; if (ln < 0 || ln + trailln > bufsz) - adios((char *)0, "arguments too long"); + adios(NULL, "arguments too long"); cp = buf + ln; - while (*++argp != (char *)0) { + while (*++argp != NULL) { ln = strlen(*argp); /* +1 for leading space */ if (ln + trailln + 1 > bufsz - (cp-buf)) - adios((char *)0, "arguments too long"); + adios(NULL, "arguments too long"); *cp++ = ' '; memcpy(cp, *argp, ln+1); cp += ln; @@ -1072,7 +1072,7 @@ sendit(char *sp, char **arg, char *file, int pushed) char *cp, buf[BUFSIZ], **argp; char **arguments, *vec[MAXARGS]; struct stat st; - char *attach = (char *)0; /* attachment header field name */ + char *attach = NULL; /* attachment header field name */ int attachformat = 0; /* mhbuild format specifier for attachments */ #ifndef lint