Up to now, we've been avoiding ctype functions like isspace, isdigit,
etc. because they are locale-dependent. Now that we have the c-ctype
functions, we can start using *them*, to make the code more readable
with changes like these:
- /* This may not work on EBCDIC. */
- if ((*p >= 'a' && *p <= 'z') ||
- (*p >= 'A' && *p <= 'Z') ||
- (*p >= '0' && *p <= '9'))
+ if (c_isalnum(*p))
- while ((*cur >= '0') && (*cur <= '9')) {
+ while (c_isdigit(*cur)) {
Also, some macros in conf.c used names that conflicted with
standard meaning of "BLANK" and "SPACE", so I've adjusted them
to be in line with the definition of e.g., isblank.
In addition, I've wrapped those statement macros with do {...} while (0),
so that we can't forget the ";" after a use. There was one like that
already (fixed below). The missing semicolon would mess up automatic
indenting.
* src/buf.c (virBufferURIEncodeString):
* src/conf.c (IS_EOL, SKIP_BLANKS_AND_EOL, SKIP_BLANKS)
(virConfParseLong, virConfParseValue, virConfParseName)
(virConfParseSeparator, virConfParseStatement, IS_BLANK, IS_CHAR)
(IS_DIGIT, IS_SPACE, SKIP_SPACES):
* src/nodeinfo.c:
* src/qemu_conf.c (qemudParseInterfaceXML):
* src/qemu_driver.c (qemudDomainBlockStats):
* src/sexpr.c:
* src/stats_linux.c:
* src/util.c (virParseNumber, virDiskNameToIndex):
* src/uuid.c (hextobin, virUUIDParse):
* src/virsh.c:
* src/xml.c (parseCpuNumber, virParseCpuSet):
Mon May 12 23:32:21 PST 2008 David L. Leskovec <dlesko@linux.vnet.ibm.com>
* qemud/qemud.c: get siginfo with signals, distribute to drivers that
register a handler
* src/driver.h: add sighandler function to state driver table
* src/internal.h: define virStateSigDispatcher functions
* src/libvirt.c: add __virStateSigDispatcher function
* src/libvirt_sym.version: add __virStateSigDispatcher
* src/lxc_driver.c: add sig handler function, cleanup vm when sigchld
received from container process
* src/qemu_driver.c: NULL for sig handler (no handler) in state driver
* src/remote_internal.c: NULL for sig handler (no handler) in state driver
* src/storage_driver.c: NULL for sig handler (no handler) in state driver
# Convert uses of isspace to c_isspace, isdigit to c_isdigit, etc.
re=$(man isspace|grep is.....,.is|sed 's/ -.*//' \
|tr -s ', \n' \||sed 's/^|//;s/|$//')
git grep -l -E "$re"|grep -Ev 'Chan|gnulib' \
|xargs perl -pi -e 's/\b('"$re"')\b/c_$1/g'
# Remove all uses of to_uchar
git grep -l to_uchar|xargs perl -pi -e 's/to_uchar\((.*?)\)/$1/g'
* src/util.h (to_uchar): Remove definition.
(TOLOWER): Remove definition.
(__virMacAddrCompare): Use c_tolower, not TOLOWER.
Globally:
Where needed, change <ctype.h> to <c-ctype.h>.
Remove unnecessary inclusion of <ctype.h>.
Ensure the global changes are never needed again:
* Makefile.maint (sc_avoid_ctype_macros): Prohibit use of ctype
macros. Recommend c-ctype.h instead.
(sc_prohibit_c_ctype_without_use): New rule.
(sc_prohibit_ctype_h): New rule. Disallow use of <ctype.h>.
* src/storage_backend_fs.c (fileTypeInfo): Add "static" and two
"const" attributes.
(FileTypeInfo): Name the previously anonymous struct,
so the declaration of fileTypeInfo looks more conventional.
* src/xend_internal.c (sound_models): Mark as static, and
as an array of "const" entries.
These were relatively new additions to the list from here:
nm src/*.o|grep ' D '