Changeset 5b7fcf9f301963803ed8fa27278591f685abf682
- Timestamp:
- 06/23/2008 12:13:26 PM
(7 months ago)
- Author:
- mitchell <mitchell@frost.(none)>
- git-committer:
- mitchell <mitchell@frost.(none)> 1214248406 -0400
- git-parent:
[3c1539eeb1e066cd00cd3114851c02578e77264e]
- git-author:
- mitchell <mitchell@frost.(none)> 1214248406 -0400
- Message:
Fixed another segfault; renamed 'queue' action to 'enqueue'.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rb354c6b |
r5b7fcf9 |
|
| 221 | 221 | defining line_start. |
|---|
| 222 | 222 | |
|---|
| 223 | | Also for multi-line matches, it may be necessary to use the 'queue' and |
|---|
| | 223 | Also for multi-line matches, it may be necessary to use the 'enqueue' and |
|---|
| 224 | 224 | 'commit' actions. If it is possible that a multi-line entity will not have |
|---|
| 225 | | an ending delimiter (for example a string), use the 'queue' action as soon |
|---|
| 226 | | as the start delimitter has been detected, and the 'commit' action as soon |
|---|
| 227 | | as the end delimitter has been detected. This will eliminate the potential |
|---|
| 228 | | for any counting errors. |
|---|
| | 225 | an ending delimiter (for example a string), use the 'enqueue' action as |
|---|
| | 226 | soon as the start delimitter has been detected, and the 'commit' action as |
|---|
| | 227 | soon as the end delimitter has been detected. This will eliminate the |
|---|
| | 228 | potential for any counting errors. |
|---|
| 229 | 229 | |
|---|
| 230 | 230 | Notes: |
|---|
| rb354c6b |
r5b7fcf9 |
|
| 42 | 42 | void enqueue(const char *lang, const char *entity, int s, int e) { |
|---|
| 43 | 43 | Callback *item = (Callback *) malloc(sizeof(Callback)); |
|---|
| 44 | | //assert(item != NULL); // trap malloc errors |
|---|
| | 44 | if (!item) printf("Failed to allocate memory for enqueued callback.\n"); |
|---|
| 45 | 45 | |
|---|
| 46 | 46 | item->lang = lang; |
|---|
| … | … | |
| 62 | 62 | void free_queue() { |
|---|
| 63 | 63 | Callback *item = callback_list_head; |
|---|
| 64 | | while (item != NULL) { |
|---|
| | 64 | while (item) { |
|---|
| 65 | 65 | Callback *next = item->next; |
|---|
| 66 | 66 | free(item); |
|---|
| 67 | 67 | item = next; |
|---|
| 68 | 68 | } |
|---|
| | 69 | callback_list_head = NULL; |
|---|
| | 70 | callback_list_tail = NULL; |
|---|
| 69 | 71 | } |
|---|
| 70 | 72 | |
|---|
| … | … | |
| 175 | 177 | */ |
|---|
| 176 | 178 | #define std_newline(lang) {\ |
|---|
| | 179 | if (inqueue) { dequeue; } \ |
|---|
| 177 | 180 | if (callback && te > line_start) { \ |
|---|
| 178 | 181 | if (line_contains_code) \ |
|---|
| rb354c6b |
r5b7fcf9 |
|
| 28 | 28 | # common actions |
|---|
| 29 | 29 | |
|---|
| 30 | | action queue { |
|---|
| | 30 | action enqueue { |
|---|
| 31 | 31 | inqueue = 1; |
|---|
| 32 | | free_queue(); // free the current queue |
|---|
| | 32 | if (callback_list_head) free_queue(); // free the current queue |
|---|
| 33 | 33 | callback_list_head = NULL; |
|---|
| 34 | 34 | callback_list_tail = NULL; |
|---|
| r3c1539e |
r5b7fcf9 |
|
| 49 | 49 | # Can't do that now because using 'when starts_line' fails a Ragel assertion. |
|---|
| 50 | 50 | ruby_block_comment = |
|---|
| 51 | | '=begin' @queue @comment ( |
|---|
| | 51 | '=begin' @enqueue @comment ( |
|---|
| 52 | 52 | newline %{ entity = INTERNAL_NL; } %ruby_ccallback |
|---|
| 53 | 53 | | |
|---|
| … | … | |
| 59 | 59 | |
|---|
| 60 | 60 | ruby_sq_str = |
|---|
| 61 | | '\'' @queue @code ( |
|---|
| | 61 | '\'' @enqueue @code ( |
|---|
| 62 | 62 | newline %{ entity = INTERNAL_NL; } %ruby_ccallback |
|---|
| 63 | 63 | | |
|---|
| … | … | |
| 69 | 69 | )* '\'' @commit @code; |
|---|
| 70 | 70 | ruby_dq_str = |
|---|
| 71 | | '"' @queue @code ( |
|---|
| | 71 | '"' @enqueue @code ( |
|---|
| 72 | 72 | newline %{ entity = INTERNAL_NL; } %ruby_ccallback |
|---|
| 73 | 73 | | |
|---|
| … | … | |
| 88 | 88 | # closing char in the literal string below. |
|---|
| 89 | 89 | ruby_lit_str = |
|---|
| 90 | | '%' [qQ]? [(\[{] @queue @code ( |
|---|
| | 90 | '%' [qQ]? [(\[{] @enqueue @code ( |
|---|
| 91 | 91 | newline %{ entity = INTERNAL_NL; } %ruby_ccallback |
|---|
| 92 | 92 | | |
|---|
| … | … | |
| 98 | 98 | )* [)\]}] @commit @code; |
|---|
| 99 | 99 | ruby_cmd_str = |
|---|
| 100 | | '`' @queue @code ( |
|---|
| | 100 | '`' @enqueue @code ( |
|---|
| 101 | 101 | newline %{ entity = INTERNAL_NL; } %ruby_ccallback |
|---|
| 102 | 102 | | |
|---|
| … | … | |
| 111 | 111 | # See TODO above about literal string detection |
|---|
| 112 | 112 | ruby_lit_other = |
|---|
| 113 | | '%' [wrx] [(\[{] @queue @code ( |
|---|
| | 113 | '%' [wrx] [(\[{] @enqueue @code ( |
|---|
| 114 | 114 | newline %{ entity = INTERNAL_NL; } %ruby_ccallback |
|---|
| 115 | 115 | | |
|---|