error: small cleanups

This commit is contained in:
rillig 2023-08-26 15:07:14 +00:00
parent 55512687bb
commit 1f3ad203f7
1 changed files with 8 additions and 17 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr.c,v 1.24 2023/08/26 14:59:44 rillig Exp $ */ /* $NetBSD: subr.c,v 1.25 2023/08/26 15:07:14 rillig Exp $ */
/* /*
* Copyright (c) 1980, 1993 * Copyright (c) 1980, 1993
@ -34,7 +34,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)subr.c 8.1 (Berkeley) 6/6/93"; static char sccsid[] = "@(#)subr.c 8.1 (Berkeley) 6/6/93";
#endif #endif
__RCSID("$NetBSD: subr.c,v 1.24 2023/08/26 14:59:44 rillig Exp $"); __RCSID("$NetBSD: subr.c,v 1.25 2023/08/26 15:07:14 rillig Exp $");
#endif /* not lint */ #endif /* not lint */
#include <ctype.h> #include <ctype.h>
@ -292,10 +292,9 @@ printerrors(bool look_at_subclass, int errorc, Eptr errorv[])
void void
wordvprint(FILE *fyle, int wordc, char **wordv) wordvprint(FILE *fyle, int wordc, char **wordv)
{ {
int i;
const char *sep = ""; const char *sep = "";
for (i = 0; i < wordc; i++) for (int i = 0; i < wordc; i++)
if (wordv[i] != NULL) { if (wordv[i] != NULL) {
fprintf(fyle, "%s%s",sep,wordv[i]); fprintf(fyle, "%s%s",sep,wordv[i]);
sep = " "; sep = " ";
@ -351,10 +350,9 @@ wordvbuild(char *string, int *r_wordc, char ***r_wordv)
int int
wordvcmp(char **wordv1, int wordc, char **wordv2) wordvcmp(char **wordv1, int wordc, char **wordv2)
{ {
int i;
int back; int back;
for (i = 0; i < wordc; i++) { for (int i = 0; i < wordc; i++) {
if (wordv1[i] == NULL || wordv2[i] == NULL) if (wordv1[i] == NULL || wordv2[i] == NULL)
return -1; return -1;
if ((back = strcmp(wordv1[i], wordv2[i])) != 0) if ((back = strcmp(wordv1[i], wordv2[i])) != 0)
@ -364,7 +362,7 @@ wordvcmp(char **wordv1, int wordc, char **wordv2)
} }
/* /*
* splice a 0 basedword vector onto the tail of a * splice a 0 based word vector onto the tail of a
* new wordv, allowing the first emptyhead slots to be empty * new wordv, allowing the first emptyhead slots to be empty
*/ */
char ** char **
@ -377,26 +375,19 @@ wordvsplice(int emptyhead, int wordc, char **wordv)
nwordv = Calloc(nwordc, sizeof (char *)); nwordv = Calloc(nwordc, sizeof (char *));
for (i = 0; i < emptyhead; i++) for (i = 0; i < emptyhead; i++)
nwordv[i] = NULL; nwordv[i] = NULL;
for (i = emptyhead; i < nwordc; i++) { for (i = emptyhead; i < nwordc; i++)
nwordv[i] = wordv[i-emptyhead]; nwordv[i] = wordv[i-emptyhead];
}
return nwordv; return nwordv;
} }
/*
* plural and verb forms
*/
static const char *S = "s";
static const char *N = "";
const char * const char *
plural(int n) plural(int n)
{ {
return n > 1 ? S : N; return n > 1 ? "s" : "";
} }
const char * const char *
verbform(int n) verbform(int n)
{ {
return n > 1 ? N : S; return n > 1 ? "" : "s";
} }