Skip to content

Commit

Permalink
Make string_length survive NULL strings like all other string_* funct…
Browse files Browse the repository at this point in the history
…ions.

git-svn-id: https://svn.parrot.org/parrot/trunk@1323 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
hotsphink committed Apr 9, 2002
1 parent daeba68 commit cf0e6d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ string_destroy(STRING *s)
UINTVAL
string_length(const STRING *s)
{
return s->strlen;
return s ? s->strlen : 0;
}

/*=for api string string_index
Expand All @@ -119,7 +119,8 @@ string_index(const STRING *s, UINTVAL idx)
}

/*=for api string string_ord
* return the length of the string
* Return the codepoint at a given index into a string. Negative
* indexes are treated as counting from the end of the string.
*/
INTVAL
string_ord(const STRING *s, INTVAL idx)
Expand Down
5 changes: 3 additions & 2 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ string_destroy(STRING *s)
UINTVAL
string_length(const STRING *s)
{
return s->strlen;
return s ? s->strlen : 0;
}

/*=for api string string_index
Expand All @@ -119,7 +119,8 @@ string_index(const STRING *s, UINTVAL idx)
}

/*=for api string string_ord
* return the length of the string
* Return the codepoint at a given index into a string. Negative
* indexes are treated as counting from the end of the string.
*/
INTVAL
string_ord(const STRING *s, INTVAL idx)
Expand Down

0 comments on commit cf0e6d7

Please sign in to comment.