]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/captoinfo.c
ncurses 6.2 - patch 20210206
[ncurses.git] / ncurses / tinfo / captoinfo.c
index a9eb1e53454d355fe9e77c7a9beafdce5e27f065..de0133b386c6b50fbafdc7ad07a493ea84b7631f 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2018,2019 Free Software Foundation, Inc.              *
+ * Copyright 2018-2019,2020 Thomas E. Dickey                                *
+ * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -97,7 +98,7 @@
 #include <ctype.h>
 #include <tic.h>
 
-MODULE_ID("$Id: captoinfo.c,v 1.97 2019/10/15 23:13:35 tom Exp $")
+MODULE_ID("$Id: captoinfo.c,v 1.100 2020/07/08 21:39:54 tom Exp $")
 
 #if 0
 #define DEBUG_THIS(p) DEBUG(9, p)
@@ -215,12 +216,15 @@ cvtchar(register const char *sp)
        }
        break;
     case '^':
+       len = 2;
        c = UChar(*++sp);
-       if (c == '?')
+       if (c == '?') {
            c = 127;
-       else
+       } else if (c == '\0') {
+           len = 1;
+       } else {
            c &= 0x1f;
-       len = 2;
+       }
        break;
     default:
        c = UChar(*sp);
@@ -635,7 +639,7 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parameteriz
     /* we may have to move some trailing mandatory padding up front */
     padding = str + strlen(str) - 1;
     if (padding > str && *padding == '>') {
-       if (*--padding == '/')
+       if (padding > (str + 1) && *--padding == '/')
            --padding;
        while (isdigit(UChar(*padding)) || *padding == '.' || *padding == '*')
            padding--;