Date: Fri, 30 Oct 2020 14:32:13 +0000 (UTC) From: =?UTF-8?Q?Stefan_E=c3=9fer?= <se@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367166 - head/usr.bin/calendar Message-ID: <202010301432.09UEWDSY076994@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: se Date: Fri Oct 30 14:32:13 2020 New Revision: 367166 URL: https://svnweb.freebsd.org/changeset/base/367166 Log: Fix length calculation in memmove MFC after: 3 days Modified: head/usr.bin/calendar/events.c head/usr.bin/calendar/io.c Modified: head/usr.bin/calendar/events.c ============================================================================== --- head/usr.bin/calendar/events.c Fri Oct 30 14:07:25 2020 (r367165) +++ head/usr.bin/calendar/events.c Fri Oct 30 14:32:13 2020 (r367166) @@ -55,6 +55,7 @@ set_new_encoding(void) const char *newenc; newenc = nl_langinfo(CODESET); + fprintf(stderr, "NEWENC=%s\n", newenc); // DEBUG if (currentEncoding == NULL) { currentEncoding = strdup(newenc); if (currentEncoding == NULL) @@ -98,13 +99,14 @@ convert(char *input) else err(1, "Initialization failure"); } + fprintf(stderr, "CONV=%p\n", conv); // DEBUG } inleft = strlen(input); inbuf = input; - outlen = inleft; - if ((output = malloc(outlen + 1)) == NULL) + outlen = inleft + 3; + if ((output = malloc(outlen)) == NULL) errx(1, "convert: cannot allocate memory"); for (;;) { @@ -112,7 +114,9 @@ convert(char *input) outbuf = output + converted; outleft = outlen - converted; + fprintf(stderr, "-< %s %p %ld %ld\n", inbuf, outbuf, inleft, outleft); // DEBUG converted = iconv(conv, (char **) &inbuf, &inleft, &outbuf, &outleft); + fprintf(stderr, "-> %ld %s %p %ld %ld\n", converted, inbuf, outbuf, inleft, outleft); // DEBUG if (converted != (size_t) -1 || errno == EINVAL) { /* finished or invalid multibyte, so truncate and ignore */ break; Modified: head/usr.bin/calendar/io.c ============================================================================== --- head/usr.bin/calendar/io.c Fri Oct 30 14:07:25 2020 (r367165) +++ head/usr.bin/calendar/io.c Fri Oct 30 14:32:13 2020 (r367166) @@ -311,16 +311,19 @@ cal_parse(FILE *in, FILE *out) c = strstr(buf, "//"); cc = strstr(buf, "/*"); if (c != NULL && (cc == NULL || c - cc < 0)) { + /* single line comment */ *c = '\0'; linelen = c - buf; break; } else if (cc != NULL) { c = strstr(cc + 2, "*/"); if (c != NULL) { + /* multi-line comment ending on same line */ c += 2; - memmove(cc, c, c - buf + linelen); + memmove(cc, c, buf + linelen + 1 - c); linelen -= c - cc; } else { + /* multi-line comment */ *cc = '\0'; linelen = cc - buf; incomment = true;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202010301432.09UEWDSY076994>