mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Improve handling of asterisks in comments
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17073 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1a87e96517
commit
649d9d7374
2 changed files with 47 additions and 14 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
* Source/Additions/Unicode.m: Add 'UTF-7' so iconv can be used to
|
||||
handle utf7 if available.
|
||||
* Tools/AGSParser.m: Don't always strip asterisks from comments,
|
||||
Check first line of comment to see if it has one first.
|
||||
|
||||
2003-06-28 15:48 Alexander Malmberg <alexander@malmberg.org>
|
||||
|
||||
|
|
|
@ -325,7 +325,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* In spite of it's trivial name, this is one of the key methods -
|
||||
* In spite of its trivial name, this is one of the key methods -
|
||||
* it parses and skips past comments, but it also recognizes special
|
||||
* comments (with an additional asterisk after the start of the block
|
||||
* comment) and extracts their contents, accumulating them into the
|
||||
|
@ -388,6 +388,7 @@
|
|||
unichar *end = &buffer[pos - 1];
|
||||
unichar *ptr = start;
|
||||
unichar *newLine = ptr;
|
||||
BOOL stripAsterisks = NO;
|
||||
|
||||
/*
|
||||
* Remove any asterisks immediately before end of comment.
|
||||
|
@ -407,7 +408,11 @@
|
|||
*end++ = '\n';
|
||||
|
||||
/*
|
||||
* Strip parts of lines up to leading asterisks.
|
||||
* If next line in the comment starts with whitespace followed
|
||||
* by an asterisk, we assume all the lines in the comment start
|
||||
* in a similar way, and everything up to and including the
|
||||
* asterisk on each line should be stripped.
|
||||
* Otherwise we take the comment verbatim.
|
||||
*/
|
||||
while (ptr < end)
|
||||
{
|
||||
|
@ -415,23 +420,49 @@
|
|||
|
||||
if (c == '\n')
|
||||
{
|
||||
newLine = ptr;
|
||||
break;
|
||||
}
|
||||
else if (c == '*' && newLine != 0)
|
||||
else if (c == '*')
|
||||
{
|
||||
unichar *out = newLine;
|
||||
|
||||
while (ptr < end)
|
||||
{
|
||||
*out++ = *ptr++;
|
||||
}
|
||||
end = out;
|
||||
ptr = newLine;
|
||||
newLine = 0;
|
||||
stripAsterisks = YES;
|
||||
break;
|
||||
}
|
||||
else if ([spaces characterIsMember: c] == NO)
|
||||
{
|
||||
newLine = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (stripAsterisks == YES)
|
||||
{
|
||||
/*
|
||||
* Strip parts of lines up to leading asterisks.
|
||||
*/
|
||||
ptr = start;
|
||||
while (ptr < end)
|
||||
{
|
||||
unichar c = *ptr++;
|
||||
|
||||
if (c == '\n')
|
||||
{
|
||||
newLine = ptr;
|
||||
}
|
||||
else if (c == '*' && newLine != 0)
|
||||
{
|
||||
unichar *out = newLine;
|
||||
|
||||
while (ptr < end)
|
||||
{
|
||||
*out++ = *ptr++;
|
||||
}
|
||||
end = out;
|
||||
ptr = newLine;
|
||||
newLine = 0;
|
||||
}
|
||||
else if ([spaces characterIsMember: c] == NO)
|
||||
{
|
||||
newLine = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue