From b36cbd5dfb16205ac53f0e8bf0392aa64b181f73 Mon Sep 17 00:00:00 2001 From: midipix Date: Jan 26 2024 14:47:57 +0000 Subject: argv.h: argv_show_error: refactor handling of vendor-specific option string. --- diff --git a/src/internal/argv/argv.h b/src/internal/argv/argv.h index 2fd8685..af27c24 100644 --- a/src/internal/argv/argv.h +++ b/src/internal/argv/argv.h @@ -536,10 +536,11 @@ static const char * argv_program_name(const char * program_path) static void argv_show_error(int fd, struct argv_ctx * ctx) { - char * ch; - char * cap; - char opt_vendor_buf[256]; - char opt_short_name[2] = {0,0}; + const char * src; + char * dst; + char * cap; + char opt_vendor_buf[256]; + char opt_short_name[2] = {0,0}; if (ctx->erropt && ctx->erropt->short_name) opt_short_name[0] = ctx->erropt->short_name; @@ -556,14 +557,22 @@ static void argv_show_error(int fd, struct argv_ctx * ctx) break; case ARGV_ERROR_VENDOR_OPTION: - memset(opt_vendor_buf,0,sizeof(opt_vendor_buf)); - strncpy(opt_vendor_buf,ctx->errch,sizeof(opt_vendor_buf) - 1); - + src = ctx->errch; + dst = opt_vendor_buf; cap = &opt_vendor_buf[sizeof(opt_vendor_buf)]; - for (ch=opt_vendor_buf; ch && *ch && ch