From 4d515819041169f6ccd82923095a3704e8c46f72 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Sat, 15 Jul 2017 09:44:21 +0100 Subject: [PATCH] #define constants in upper case --- commands.c | 6 +++--- handler.c | 8 ++++---- pager.c | 6 +++--- recvcmd.c | 6 +++--- smtp.c | 44 ++++++++++++++++++++++---------------------- txt2c.c | 6 +++--- 6 files changed, 38 insertions(+), 38 deletions(-) diff --git a/commands.c b/commands.c index bb1a86bc5..8be3204d8 100644 --- a/commands.c +++ b/commands.c @@ -318,13 +318,13 @@ void ci_bounce_message(struct Header *h) buf[0] = 0; rfc822_write_address(buf, sizeof(buf), adr, 1); -#define extra_space (15 + 7 + 2) +#define EXTRA_SPACE (15 + 7 + 2) snprintf(scratch, sizeof(scratch), (h ? _("Bounce message to %s") : _("Bounce messages to %s")), buf); - if (mutt_strwidth(prompt) > MuttMessageWindow->cols - extra_space) + if (mutt_strwidth(prompt) > MuttMessageWindow->cols - EXTRA_SPACE) { - mutt_simple_format(prompt, sizeof(prompt), 0, MuttMessageWindow->cols - extra_space, + mutt_simple_format(prompt, sizeof(prompt), 0, MuttMessageWindow->cols - EXTRA_SPACE, FMT_LEFT, 0, scratch, sizeof(scratch), 0); safe_strcat(prompt, sizeof(prompt), "...?"); } diff --git a/handler.c b/handler.c index 172298083..b8cca5425 100644 --- a/handler.c +++ b/handler.c @@ -471,7 +471,7 @@ static void decode_uuencoded(struct State *s, long len, int istext, iconv_t cd) * A (not so) minimal implementation of RFC1563. */ -#define IndentSize (4) +#define INDENT_SIZE 4 /** * enum RichAttribs - Rich text attributes @@ -577,7 +577,7 @@ static void enriched_wrap(struct EnrichedState *stte) } extra = stte->wrap_margin - stte->line_len - stte->indent_len - - (stte->tag_level[RICH_INDENT_RIGHT] * IndentSize); + (stte->tag_level[RICH_INDENT_RIGHT] * INDENT_SIZE); if (extra > 0) { if (stte->tag_level[RICH_CENTER]) @@ -635,7 +635,7 @@ static void enriched_wrap(struct EnrichedState *stte) stte->indent_len = 0; if (stte->tag_level[RICH_INDENT]) { - x = stte->tag_level[RICH_INDENT] * IndentSize; + x = stte->tag_level[RICH_INDENT] * INDENT_SIZE; stte->indent_len += x; while (x) { @@ -649,7 +649,7 @@ static void enriched_flush(struct EnrichedState *stte, int wrap) { if (!stte->tag_level[RICH_NOFILL] && (stte->line_len + stte->word_len > - (stte->wrap_margin - (stte->tag_level[RICH_INDENT_RIGHT] * IndentSize) - stte->indent_len))) + (stte->wrap_margin - (stte->tag_level[RICH_INDENT_RIGHT] * INDENT_SIZE) - stte->indent_len))) enriched_wrap(stte); if (stte->buff_used) diff --git a/pager.c b/pager.c index 334602c6e..b7d73f166 100644 --- a/pager.c +++ b/pager.c @@ -185,13 +185,13 @@ static struct Resize } *Resize = NULL; #endif -#define NumSigLines 4 +#define NUM_SIG_LINES 4 static int check_sig(const char *s, struct Line *info, int n) { int count = 0; - while (n > 0 && count <= NumSigLines) + while (n > 0 && count <= NUM_SIG_LINES) { if (info[n].type != MT_COLOR_SIGNATURE) break; @@ -202,7 +202,7 @@ static int check_sig(const char *s, struct Line *info, int n) if (count == 0) return -1; - if (count > NumSigLines) + if (count > NUM_SIG_LINES) { /* check for a blank line */ while (*s) diff --git a/recvcmd.c b/recvcmd.c index 74faabcf2..a26ea0332 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -193,16 +193,16 @@ void mutt_attach_bounce(FILE *fp, struct Header *hdr, struct AttachPtr **idx, buf[0] = 0; rfc822_write_address(buf, sizeof(buf), adr, 1); -#define extra_space (15 + 7 + 2) +#define EXTRA_SPACE (15 + 7 + 2) /* * See commands.c. */ snprintf(prompt, sizeof(prompt) - 4, (p ? _("Bounce message to %s") : _("Bounce messages to %s")), buf); - if (mutt_strwidth(prompt) > MuttMessageWindow->cols - extra_space) + if (mutt_strwidth(prompt) > MuttMessageWindow->cols - EXTRA_SPACE) { - mutt_simple_format(prompt, sizeof(prompt) - 4, 0, MuttMessageWindow->cols - extra_space, + mutt_simple_format(prompt, sizeof(prompt) - 4, 0, MuttMessageWindow->cols - EXTRA_SPACE, FMT_LEFT, 0, prompt, sizeof(prompt), 0); safe_strcat(prompt, sizeof(prompt), "...?"); } diff --git a/smtp.c b/smtp.c index 69c65e623..a6c139fc6 100644 --- a/smtp.c +++ b/smtp.c @@ -54,12 +54,12 @@ #endif #define smtp_success(x) ((x) / 100 == 2) -#define smtp_ready 334 -#define smtp_continue 354 +#define SMTP_READY 334 +#define SMTP_CONTINUE 354 -#define smtp_err_read -2 -#define smtp_err_write -3 -#define smtp_err_code -4 +#define SMTP_ERR_READ -2 +#define SMTP_ERR_WRITE -3 +#define SMTP_ERR_CODE -4 #define SMTP_PORT 25 #define SMTPS_PORT 465 @@ -119,7 +119,7 @@ static int smtp_get_resp(struct Connection *conn) if (n < 4) { /* read error, or no response code */ - return smtp_err_read; + return SMTP_ERR_READ; } if (ascii_strncasecmp("8BITMIME", buf + 4, 8) == 0) @@ -138,11 +138,11 @@ static int smtp_get_resp(struct Connection *conn) mutt_bit_set(Capabilities, SMTPUTF8); if (!valid_smtp_code(buf, n, &n)) - return smtp_err_code; + return SMTP_ERR_CODE; } while (buf[3] == '-'); - if (smtp_success(n) || n == smtp_continue) + if (smtp_success(n) || n == SMTP_CONTINUE) return 0; mutt_error(_("SMTP session failed: %s"), buf); @@ -167,7 +167,7 @@ static int smtp_rcpt_to(struct Connection *conn, const struct Address *a) else snprintf(buf, sizeof(buf), "RCPT TO:<%s>\r\n", a->mailbox); if (mutt_socket_write(conn, buf) == -1) - return smtp_err_write; + return SMTP_ERR_WRITE; if ((r = smtp_get_resp(conn))) return r; a = a->next; @@ -200,7 +200,7 @@ static int smtp_data(struct Connection *conn, const char *msgfile) if (mutt_socket_write(conn, buf) == -1) { safe_fclose(&fp); - return smtp_err_write; + return SMTP_ERR_WRITE; } if ((r = smtp_get_resp(conn))) { @@ -219,26 +219,26 @@ static int smtp_data(struct Connection *conn, const char *msgfile) if (mutt_socket_write_d(conn, ".", -1, MUTT_SOCK_LOG_FULL) == -1) { safe_fclose(&fp); - return smtp_err_write; + return SMTP_ERR_WRITE; } } if (mutt_socket_write_d(conn, buf, -1, MUTT_SOCK_LOG_FULL) == -1) { safe_fclose(&fp); - return smtp_err_write; + return SMTP_ERR_WRITE; } mutt_progress_update(&progress, ftell(fp), -1); } if (!term && buflen && mutt_socket_write_d(conn, "\r\n", -1, MUTT_SOCK_LOG_FULL) == -1) { safe_fclose(&fp); - return smtp_err_write; + return SMTP_ERR_WRITE; } safe_fclose(&fp); /* terminate the message body */ if (mutt_socket_write(conn, ".\r\n") == -1) - return smtp_err_write; + return SMTP_ERR_WRITE; if ((r = smtp_get_resp(conn))) return r; @@ -359,7 +359,7 @@ static int smtp_helo(struct Connection *conn) * currently doesn't check for a short write. */ if (mutt_socket_write(conn, buf) == -1) - return smtp_err_write; + return SMTP_ERR_WRITE; return smtp_get_resp(conn); } @@ -420,7 +420,7 @@ static int smtp_auth_sasl(struct Connection *conn, const char *mechlist) if (!valid_smtp_code(buf, rc, &rc)) goto fail; - if (rc != smtp_ready) + if (rc != SMTP_READY) break; if (sasl_decode64(buf + 4, strlen(buf + 4), buf, bufsize - 1, &len) != SASL_OK) @@ -451,7 +451,7 @@ static int smtp_auth_sasl(struct Connection *conn, const char *mechlist) } } strfcpy(buf + len, "\r\n", bufsize - len); - } while (rc == smtp_ready && saslrc != SASL_FAIL); + } while (rc == SMTP_READY && saslrc != SASL_FAIL); if (smtp_success(rc)) { @@ -603,7 +603,7 @@ static int smtp_open(struct Connection *conn) if (rc == MUTT_YES) { if (mutt_socket_write(conn, "STARTTLS\r\n") < 0) - return smtp_err_write; + return SMTP_ERR_WRITE; if ((rc = smtp_get_resp(conn))) return rc; @@ -692,7 +692,7 @@ int mutt_smtp_send(const struct Address *from, const struct Address *to, safe_strncat(buf, sizeof(buf), "\r\n", 3); if (mutt_socket_write(conn, buf) == -1) { - ret = smtp_err_write; + ret = SMTP_ERR_WRITE; break; } if ((ret = smtp_get_resp(conn))) @@ -715,11 +715,11 @@ int mutt_smtp_send(const struct Address *from, const struct Address *to, if (conn) mutt_socket_close(conn); - if (ret == smtp_err_read) + if (ret == SMTP_ERR_READ) mutt_error(_("SMTP session failed: read error")); - else if (ret == smtp_err_write) + else if (ret == SMTP_ERR_WRITE) mutt_error(_("SMTP session failed: write error")); - else if (ret == smtp_err_code) + else if (ret == SMTP_ERR_CODE) mutt_error(_("Invalid server response")); return ret; diff --git a/txt2c.c b/txt2c.c index 1a0d21d67..207562b4a 100644 --- a/txt2c.c +++ b/txt2c.c @@ -21,18 +21,18 @@ #include #include -#define per_line 12 +#define PER_LINE 12 static void txt2c(char *sym, FILE *fp) { - unsigned char buf[per_line]; + unsigned char buf[PER_LINE]; int i; int sz = 0; printf("unsigned char %s[] = {\n", sym); while (true) { - sz = fread(buf, sizeof(unsigned char), per_line, fp); + sz = fread(buf, sizeof(unsigned char), PER_LINE, fp); if (sz == 0) break; printf("\t"); -- 2.40.0