]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_slkset.c
ncurses 6.2 - patch 20200404
[ncurses.git] / ncurses / base / lib_slkset.c
index ca66266855eaec884ecb1e094750405a81a53626..3e777f14651cf7ba13f1e31d12c8d95fbd6cc825 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc.              *
+ * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 1998-2011,2012 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            *
 #endif
 #endif
 
-MODULE_ID("$Id: lib_slkset.c,v 1.22 2011/10/22 16:58:26 tom Exp $")
+MODULE_ID("$Id: lib_slkset.c,v 1.26 2020/02/02 23:34:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(slk_set) (NCURSES_SP_DCLx int i, const char *astr, int format)
 {
     SLK *slk;
-    int offset;
+    int offset = 0;
     int numchrs;
     int numcols;
     int limit;
@@ -89,9 +90,9 @@ NCURSES_SP_NAME(slk_set) (NCURSES_SP_DCLx int i, const char *astr, int format)
        mbrtowc(&wc, p, need, &state);
        if (!iswprint((wint_t) wc))
            break;
-       if (wcwidth(wc) + numcols > limit)
+       if (_nc_wacs_width(wc) + numcols > limit)
            break;
-       numcols += wcwidth(wc);
+       numcols += _nc_wacs_width(wc);
        p += need;
     }
     numchrs = (int) (p - str);
@@ -117,7 +118,6 @@ NCURSES_SP_NAME(slk_set) (NCURSES_SP_DCLx int i, const char *astr, int format)
        returnCode(ERR);
 
     switch (format) {
-    default:
     case 0:                    /* left-justified */
        offset = 0;
        break;