"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "extension/ordchr.c" between
gawk-5.0.1.tar.xz and gawk-5.1.0.tar.xz

About: GNU awk - pattern scanning and processing language.

ordchr.c  (gawk-5.0.1.tar.xz):ordchr.c  (gawk-5.1.0.tar.xz)
skipping to change at line 12 skipping to change at line 12
* ordchr.c - Builtin functions that provide ord() and chr() functions. * ordchr.c - Builtin functions that provide ord() and chr() functions.
* *
* Arnold Robbins * Arnold Robbins
* arnold@skeeve.com * arnold@skeeve.com
* 8/2001 * 8/2001
* Revised 6/2004 * Revised 6/2004
* Revised 5/2012 * Revised 5/2012
*/ */
/* /*
* Copyright (C) 2001, 2004, 2011, 2012, 2013, 2018 * Copyright (C) 2001, 2004, 2011, 2012, 2013, 2018, 2020,
* the Free Software Foundation, Inc. * the Free Software Foundation, Inc.
* *
* This file is part of GAWK, the GNU implementation of the * This file is part of GAWK, the GNU implementation of the
* AWK Programming Language. * AWK Programming Language.
* *
* GAWK is free software; you can redistribute it and/or modify * GAWK is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
skipping to change at line 72 skipping to change at line 72
do_ord(int nargs, awk_value_t *result, struct awk_ext_func *unused) do_ord(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{ {
awk_value_t str; awk_value_t str;
double ret = -1; double ret = -1;
assert(result != NULL); assert(result != NULL);
if (get_argument(0, AWK_STRING, & str)) { if (get_argument(0, AWK_STRING, & str)) {
ret = str.str_value.str[0]; ret = str.str_value.str[0];
} else if (do_lint) } else if (do_lint)
lintwarn(ext_id, _("ord: called with inappropriate argument(s)")) ; lintwarn(ext_id, _("ord: first argument is not a string"));
/* Set the return value */ /* Set the return value */
return make_number(ret, result); return make_number(ret, result);
} }
/* do_chr --- turn numeric value into a string */ /* do_chr --- turn numeric value into a string */
static awk_value_t * static awk_value_t *
do_chr(int nargs, awk_value_t *result, struct awk_ext_func *unused) do_chr(int nargs, awk_value_t *result, struct awk_ext_func *unused)
{ {
skipping to change at line 99 skipping to change at line 99
assert(result != NULL); assert(result != NULL);
if (get_argument(0, AWK_NUMBER, & num)) { if (get_argument(0, AWK_NUMBER, & num)) {
val = num.num_value; val = num.num_value;
ret = val; /* convert to int */ ret = val; /* convert to int */
ret &= 0xff; ret &= 0xff;
str[0] = ret; str[0] = ret;
str[1] = '\0'; str[1] = '\0';
} else if (do_lint) } else if (do_lint)
lintwarn(ext_id, _("chr: called with inappropriate argument(s)")) ; lintwarn(ext_id, _("chr: first argument is not a number"));
/* Set the return value */ /* Set the return value */
return make_const_string(str, 1, result); return make_const_string(str, 1, result);
} }
static awk_ext_func_t func_table[] = { static awk_ext_func_t func_table[] = {
{ "ord", do_ord, 1, 1, awk_false, NULL }, { "ord", do_ord, 1, 1, awk_false, NULL },
{ "chr", do_chr, 1, 1, awk_false, NULL }, { "chr", do_chr, 1, 1, awk_false, NULL },
}; };
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)