uawk: possibilité de lancer les versions locale-aware

This commit is contained in:
Jephté Clain 2017-08-25 15:45:39 +04:00
parent ef00e07b21
commit e4f154efc6
2 changed files with 19 additions and 13 deletions

View File

@ -1140,19 +1140,17 @@ function lawkcsv2fsv() {
done done
shift shift
lawkcsv -v fields[@] -v sizes[@] -a ' lawkcsv -v fields[@] -v sizes[@] -a '{
{
line = "" line = ""
for (i = 1; i <= fields_count; i++) { for (i = 1; i <= fields_count; i++) {
size = sizes[i] + 0 size = sizes[i] + 0
value = get(fields[i]) value = get(fields[i]) ""
while (length(value) < size) value = value " " while (length(value) < size) value = value " "
if (length(value) > size) value = substr(value, 1, size) if (length(value) > size) value = substr(value, 1, size)
line = line value line = line value
} }
print line print line
} }' -- "$@"
' -- "$@"
} }
function cawkcsv2fsv() { LANG=C lawkcsv2fsv "$@"; } function cawkcsv2fsv() { LANG=C lawkcsv2fsv "$@"; }

24
uawk
View File

@ -45,14 +45,22 @@ fi
# Aliases pour les noms d'outils # Aliases pour les noms d'outils
case "$tool" in case "$tool" in
run) tool=awkrun;; run) tool=awkrun; toolprefix=; prefix=c; Clang=1;;
csv) tool=awkcsv;; lrun) tool=awkrun; toolprefix=l; prefix=l; Clang=;;
grep) tool=grepcsv;; csv) tool=awkcsv; toolprefix=; prefix=c; Clang=1;;
fsv2csv|fsv) tool=awkfsv2csv;; lcsv) tool=awkcsv; toolprefix=l; prefix=l; Clang=;;
csv2fsv) tool=awkcsv2fsv;; grep) tool=grepcsv; toolprefix=; prefix=c; Clang=1;;
merge) tool=mergecsv;; lgrep) tool=grepcsv; toolprefix=l; prefix=l; Clang=;;
sort) tool=sortcsv;; fsv2csv|fsv) tool=awkfsv2csv; toolprefix=; prefix=c; Clang=1;;
dump) tool=dumpcsv;; lfsv2csv|lfsv) tool=awkfsv2csv; toolprefix=l; prefix=l; Clang=;;
csv2fsv) tool=awkcsv2fsv; toolprefix=; prefix=c; Clang=1;;
lcsv2fsv) tool=awkcsv2fsv; toolprefix=l; prefix=l; Clang=;;
merge) tool=mergecsv; toolprefix=; prefix=c; Clang=1;;
lmerge) tool=mergecsv; toolprefix=l; prefix=l; Clang=;;
sort) tool=sortcsv; toolprefix=; prefix=c; Clang=1;;
lsort) tool=sortcsv; toolprefix=l; prefix=l; Clang=;;
dump) tool=dumpcsv; toolprefix=; prefix=c; Clang=1;;
ldump) tool=dumpcsv; toolprefix=l; prefix=l; Clang=;;
esac esac
scriptname="$toolprefix$tool" scriptname="$toolprefix$tool"