summaryrefslogtreecommitdiffstats
path: root/lib/mbsalign.c
Commit message (Collapse)AuthorAgeFilesLines
* lib/mbsalign: Fix escaping nonprintable multibyte charactersVaclav Dolezal2018-01-111-1/+1
| | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* lib/mbsalign: escape "\x" when HAVE_WIDECHAR not definedVaclav Dolezal2017-12-221-4/+3Star
| | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* lib/mbsalign: encode \x to \xecxKarel Zak2017-12-201-2/+8
| | | | | | | Don't encode stand alone '\', our encoding is about \x<hex>, so we need to care about \x prefix only. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/mbsalign: encode backslash to prevent ambiguityVaclav Dolezal2017-11-291-2/+2
| | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* lib/mbsalign: add mbs_invalid_encode()Karel Zak2017-11-221-0/+80
| | | | | | Like mbs_safe_encode(), but it does not care about control chars. Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: remove stray semicolonsSami Kerola2017-06-141-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/mbsalign: free buffer after error [coverity scan]Karel Zak2016-10-041-5/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: support multi-line cells based on line breaksKarel Zak2016-09-061-3/+9
| | | | | | | | | | Now libsmartcols completely control when and how wrap long lines/cells. This is sometimes user unfriendly and it would be nice to support multi-line cells where wrap is based on \n (new line char). This patch add new column flag SCOLS_FL_WRAPNL. Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: cleanup non-widechar compilationKarel Zak2016-06-031-1/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/mbsalign: fix for non-widecharKarel Zak2016-06-031-10/+12
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: include strutils.h for mempcpy()Ruediger Meier2016-02-291-0/+1
| | | | | | | | | | | | | | | | | We have that mempcpy fallback since 2013 (02887b73) but forgot to include it. This fixes a segfault of cal(1) on FreeBSD and OSX. Compiler warning was: lib/mbsalign.c:468:14: warning: implicit declaration of function 'mempcpy' is invalid in C99 [-Wimplicit-function-declaration] dest = mempcpy (dest, str_to_print, min (n_used_bytes, space_left)); ^ lib/mbsalign.c:468:12: warning: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion] dest = mempcpy (dest, str_to_print, min (n_used_bytes, space_left)); CC: Daniel Trebbien <dtrebbien@gmail.com> Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libsmartcols: support multi-line cellsKarel Zak2016-02-101-1/+2
| | | | | | | | | | | The initial implementation has been introduced by SCOLS_FL_WRAP columns, but this patch clean ups all and makes things more elegant. Note that use SCOLS_FL_TREE | SCOLS_FL_WRAP for a column is bad idea and I don't think we need to fix it. References: https://github.com/karelzak/util-linux/issues/269 Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: support multibyte titles, rename wrap to paddingKarel Zak2016-01-221-6/+14
| | | | | | | | | - let's support multibyte table titles - use lib/mbalign.c to align the title - rename title_wrap to title_padding (we already use "wrap" on another places for another things) Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/mbsalign: fix warnings when compile without widecharsKarel Zak2016-01-131-5/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/mbalign: fix unsigned integer overflow [AddressSanitizer]Sami Kerola2014-12-191-1/+1
| | | | | | | | | This error was reported 155 times. lib/mbsalign.c:322:18: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'size_t' (aka 'unsigned long') Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/mbalign: report also size in bytesKarel Zak2014-04-151-10/+30
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/mbsalign: split mbs_safe_encode()Karel Zak2014-04-151-12/+33
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/mbalign: add mbs_safe_width() from tt.cKarel Zak2014-03-111-1/+136
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/mbsalign: initializations values are never read [clang-analyzer]Sami Kerola2013-07-091-2/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* various: fix variable and function declarations [smatch scan]Sami Kerola2013-04-091-2/+2
| | | | | | | | | | | | | | | | | disk-utils/fsck.minix.c:511:9: warning: mixing declarations and code fdisks/sfdisk.c:982:5: warning: mixing declarations and code fdisks/sfdisk.c:1254:5: warning: mixing declarations and code fdisks/sfdisk.c:1564:5: warning: mixing declarations and code lib/mbsalign.c:279:7: warning: mixing declarations and code libblkid/src/devname.c:378:17: warning: mixing declarations and code libfdisk/src/alignment.c:219:9: warning: mixing declarations and code term-utils/wall.c:111:9: warning: mixing declarations and code text-utils/col.c:418:19: warning: non-ANSI function declaration of function 'flush_blanks' text-utils/col.c:553:12: warning: non-ANSI function declaration of function 'alloc_line' text-utils/rev.c:105:9: warning: mixing declarations and code text-utils/tailf.c:245:9: warning: mixing declarations and code Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/mbsalign: correct license header from GPLv[23] to LGPLv2+Pádraig Brady2013-03-201-2/+2
| | | | | | * lib/mbsalign.c: s/GPLv3/LGPLv2+/ * include/mbsalign.h: s/GPLv2/LGPLv2+/ * README.licensing: Remove mention GPLv3 as it's not actually used.
* lib/mbsalign: abort() when non-expected case is encounteredSami Kerola2012-06-171-0/+2
| | | | | | | | | | Fixes the following compiler warning (9 occurrences), and makes program to crash if mbsaligh() is called with unexpected align value (which would be programming error). ../lib/mbsalign.c:260:7: warning: switch missing default case [-Wswitch-default] Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* cfdisk: data type mismatch, and other, compiler warning fixesSami Kerola2011-01-251-3/+3
| | | | | | | | | | | | | | | | | | Following warnings will longer appear when one will compile with gcc flags -Wall -Wextra -pedantic cfdisk.c:475:3: warning: comparison of unsigned expression < 0 is always false cfdisk.c:487:16: warning: comparison between signed and unsigned integer expressions cfdisk.c:492:14: warning: comparison between signed and unsigned integer expressions cfdisk.c:565:19: warning: comparison between signed and unsigned integer expressions cfdisk.c:569:19: warning: comparison between signed and unsigned integer expressions cfdisk.c:1070:14: warning: comparison between signed and unsigned integer expressions cfdisk.c:1568:5: warning: missing initializer cfdisk.c:1568:5: warning: (near initialization for 'tmp_ext.volume_label') mbsalign.c:131:2: warning: comparison of unsigned expression >= 0 is always true Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* cfdisk: support non-ascii characters in inputKarel Zak2010-05-071-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | On Sat, Apr 03, 2010 at 12:58:48PM +0000, Jorge wrote: > When you want to write changes to disk you're asked for a > confirmation, like this one: > > Are you sure you want to write the partition table to disk? (yes > or no) > > There is no problem on the English version, but when you launch the > program in Spanish you get this: > > ¿Está seguro de que desea escribir la tabla de particiones en el > disco? > (sí o no): > > You can't type the "í" character. Trying to do so will end in no > input at all. That is, typing in my keyboard "´" then "i" leads to > nothing. So you can't write changes to disk, and you must launch the > program in English for it to operate. Reported-by: Jorge <yo@jorgesuarezdelis.name> Addresses: https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/205327 Signed-off-by: Karel Zak <kzak@redhat.com>
* cal: factor out and update multibyte alignment codePádraig Brady2010-03-161-0/+254
* include/mbsalign.h: New module interface * lib/mbsalign.c: Updated implementation synced from coreutils * include/Makefile.am: Add mbsalign.h * misc-utils/Makefile.am: Make cal dependent on mbsalign module * misc-utils/cal.c: Call mbsalign() [kzak@redhat.com: - use min() macro from c.h] Signed-off-by: Pádraig Brady <P@draigBrady.com> Signed-off-by: Karel Zak <kzak@redhat.com>