| T X T _ N O C O M M E N T ( )
| | | | | SOURCE: qdev_autodocs.txt 1.163 (12/09/2014) English
INDEP - TXT_#?
----------------------------------------------------------------------------
NAME
txt_nocomment() - Focuses on a text diregarding comments
and other useless things.
SYNOPSIS
ptr = txt_nocomment(string, dir);
UBYTE *txt_nocomment(UBYTE *, LONG);
FUNCTION
This function allows to strip AmigaDOS(';') or UNIX('#') or
C++('//') or C('/**/') style comments plus skips on tabs,
spaces, quotes, dbl. quotes, newlines, carriage returns, so
as a result user gets pointer(s) to real start of and/or
end of NULL term. text.
INPUTS
string - NULL terminated string.
dir - Direction of parsing, QDEV_TXT_NC_F_REW = from
right to left, QDEV_TXT_NC_F_FWD = from left to
right. This argument is considered flag holder
too.
RETURNS
Returns pointer to the first byte at which real text starts,
or byte past end of real text(so it can be NULL terminated
for instance).
BASES
None.
NOTES
Single byte comments like ';' or '#' or double byte '//' at
the beginning of the line will cause NULL when direction is
QDEV_TXT_NC_F_REW. Usually you should always parse from
right to left to see if line is "blank" or not.
Single byte comments when put inside double quotes will not
be treated as comments. This: ";text" is not a comment!
C style comments cannot be stripped when put inside a valid
text. This: "te/*comment*/xt" will not be fixed!
If working on an original buffer, dont forget to restore its
contents if you modify it!
See source code of 'i-txt_iniparse.c' for a practical use.
SEE ALSO
EXAMPLE
...
UBYTE *data = "/* comment */ \t \t 'Hi there!'"
" ;# \t /* another one */ \" ### \"";
UBYTE *ptr;
UBYTE tmp;
if ((ptr = txt_nocomment(data, QDEV_TXT_NC_F_REW)))
{
tmp = *ptr;
*ptr = '\0';
FPrintf(Output(), "%s\n",
(LONG)txt_nocomment(data, QDEV_TXT_NC_F_FWD));
*ptr = tmp;
}
BUGS
None known.
----------------------------------------------------------------------------
| |
| |