From: op Date: Wed, 22 Mar 2023 18:10:07 +0000 (+0000) Subject: delete trailing whitespaces; no functional change X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=98bbc197fd9889beaed753ba70f7be4e1eb696ed;p=openbsd delete trailing whitespaces; no functional change --- diff --git a/usr.bin/mg/tags.c b/usr.bin/mg/tags.c index f2976f9ac9b..7bf0e91993d 100644 --- a/usr.bin/mg/tags.c +++ b/usr.bin/mg/tags.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tags.c,v 1.19 2023/03/08 04:43:11 guenther Exp $ */ +/* $OpenBSD: tags.c,v 1.20 2023/03/22 18:10:07 op Exp $ */ /* * This file is in the public domain. @@ -75,16 +75,16 @@ tagsvisit(int f, int n) { char fname[NFILEN], *bufp, *temp; struct stat sb; - + if (getbufcwd(fname, sizeof(fname)) == FALSE) fname[0] = '\0'; - + if (strlcat(fname, DEFAULTFN, sizeof(fname)) >= sizeof(fname)) { dobeep(); ewprintf("Filename too long"); return (FALSE); } - + bufp = eread("Visit tags table (default %s): ", fname, NFILEN, EFFILE | EFCR | EFNEW | EFDEF, DEFAULTFN); if (bufp == NULL) @@ -103,7 +103,7 @@ tagsvisit(int f, int n) ewprintf("Cannot access file %s", bufp); return (FALSE); } - + if (tagsfn == NULL) { if (bufp[0] == '\0') { if ((tagsfn = strdup(fname)) == NULL) { @@ -160,13 +160,13 @@ findtag(int f, int n) tok = dtok; else tok = utok; - + if (tok[0] == '\0') { dobeep(); ewprintf("There is no default tag"); return (FALSE); } - + if (tagsfn == NULL) if ((ret = tagsvisit(f, n)) != TRUE) return (ret); @@ -188,7 +188,7 @@ void unloadtags(void) { struct ctag *var, *nxt; - + for (var = RB_MIN(tagtree, &tags); var != NULL; var = nxt) { nxt = RB_NEXT(tagtree, &tags, var); RB_REMOVE(tagtree, &tags, var); @@ -199,7 +199,7 @@ unloadtags(void) } /* - * Lookup tag passed in tree and if found, push current location and + * Lookup tag passed in tree and if found, push current location and * buffername onto stack, load the file with tag definition into a new * buffer and position dot at the pattern. */ @@ -210,10 +210,10 @@ pushtag(char *tok) struct tagpos *s; char bname[NFILEN]; int doto, dotline; - + if ((res = searchtag(tok)) == NULL) return (FALSE); - + doto = curwp->w_doto; dotline = curwp->w_dotline; /* record absolute filenames. Fixes issues when mg's cwd is not the @@ -228,11 +228,11 @@ pushtag(char *tok) dobeep(); ewprintf("filename too long"); return (FALSE); - } + } if (loadbuffer(res->fname) == FALSE) return (FALSE); - + if (searchpat(res->pat) == TRUE) { if ((s = malloc(sizeof(struct tagpos))) == NULL) { dobeep(); @@ -266,7 +266,7 @@ poptag(int f, int n) { struct line *dotp; struct tagpos *s; - + if (SLIST_EMPTY(&shead)) { dobeep(); ewprintf("No previous location for find-tag invocation"); @@ -278,15 +278,15 @@ poptag(int f, int n) return (FALSE); curwp->w_dotline = s->dotline; curwp->w_doto = s->doto; - + /* storing of dotp in tagpos wouldn't work out in cases when * that buffer is killed by user(dangling pointer). Explicitly - * traverse till dotline for correct handling. + * traverse till dotline for correct handling. */ dotp = curwp->w_bufp->b_headp; while (s->dotline--) dotp = dotp->l_fp; - + curwp->w_dotp = dotp; free(s->bname); free(s); @@ -294,7 +294,7 @@ poptag(int f, int n) } /* - * Parse the tags file and construct the tags tree. Remove escape + * Parse the tags file and construct the tags tree. Remove escape * characters while parsing the file. */ int @@ -302,7 +302,7 @@ loadtags(const char *fn) { char *l; FILE *fd; - + if ((fd = fopen(fn, "r")) == NULL) { dobeep(); ewprintf("Unable to open tags file: %s", fn); @@ -325,8 +325,8 @@ loadtags(const char *fn) void closetags(void) { - struct tagpos *s; - + struct tagpos *s; + while (!SLIST_EMPTY(&shead)) { s = SLIST_FIRST(&shead); SLIST_REMOVE_HEAD(&shead, entry); @@ -340,24 +340,24 @@ closetags(void) /* * Strip away any special characters in pattern. * The pattern in ctags isn't a true regular expression. Its of the form - * /^xxx$/ or ?^xxx$? and in some cases the "$" would be missing. Strip + * /^xxx$/ or ?^xxx$? and in some cases the "$" would be missing. Strip * the leading and trailing special characters so the pattern matching - * would be a simple string compare. Escape character is taken care by + * would be a simple string compare. Escape character is taken care by * fparseln. */ char * strip(char *s, size_t len) { - /* first strip trailing special chars */ + /* first strip trailing special chars */ s[len - 1] = '\0'; if (s[len - 2] == '$') s[len - 2] = '\0'; - + /* then strip leading special chars */ s++; if (*s == '^') s++; - + return s; } @@ -370,7 +370,7 @@ int addctag(char *l) { struct ctag *t; - + if ((t = malloc(sizeof(struct ctag))) == NULL) { dobeep(); ewprintf("Out of memory"); @@ -424,7 +424,7 @@ searchpat(char *s_pat) } /* - * Return TRUE if dot is at beginning of a word or at beginning + * Return TRUE if dot is at beginning of a word or at beginning * of line, else FALSE. */ int @@ -447,7 +447,7 @@ curtoken(int f, int n, char *token) struct line *odotp; int odoto, tdoto, odotline, size, r; char c; - + /* Underscore character is to be treated as "inword" while * processing tokens unlike mg's default word traversal. Save * and restore its cinfo value so that tag matching works for @@ -455,38 +455,38 @@ curtoken(int f, int n, char *token) */ c = cinfo['_']; cinfo['_'] = _MG_W; - + odotp = curwp->w_dotp; odoto = curwp->w_doto; odotline = curwp->w_dotline; - + /* Move backward unless we are at the beginning of a word or at * beginning of line. */ if (!atbow()) if ((r = backword(f, n)) == FALSE) goto cleanup; - + tdoto = curwp->w_doto; if ((r = forwword(f, n)) == FALSE) goto cleanup; - + /* strip away leading whitespace if any like emacs. */ - while (ltext(curwp->w_dotp) && + while (ltext(curwp->w_dotp) && isspace(lgetc(curwp->w_dotp, tdoto))) tdoto++; size = curwp->w_doto - tdoto; - if (size <= 0 || size >= MAX_TOKEN || + if (size <= 0 || size >= MAX_TOKEN || ltext(curwp->w_dotp) == NULL) { r = FALSE; goto cleanup; - } + } strncpy(token, ltext(curwp->w_dotp) + tdoto, size); token[size] = '\0'; r = TRUE; - + cleanup: cinfo['_'] = c; curwp->w_dotp = odotp; @@ -516,7 +516,7 @@ searchtag(char *tok) * This is equivalent to filevisit from file.c. * Look around to see if we can find the file in another buffer; if we * can't find it, create a new buffer, read in the text, and switch to - * the new buffer. *scratch*, *grep*, *compile* needs to be handled + * the new buffer. *scratch*, *grep*, *compile* needs to be handled * differently from other buffers which have "filenames". */ int @@ -533,7 +533,7 @@ loadbuffer(char *bname) } else { return (FALSE); } - } else { + } else { if ((adjf = adjustname(bname, TRUE)) == NULL) return (FALSE); if ((bufp = findbuffer(adjf)) == NULL)