Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2010 Robert Bieber |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License |
| 14 | * as published by the Free Software Foundation; either version 2 |
| 15 | * of the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 20 | ****************************************************************************/ |
| 21 | |
| 22 | #include <stdio.h> |
| 23 | #include <stdlib.h> |
| 24 | #include <string.h> |
| 25 | |
| 26 | #include "skin_parser.h" |
| 27 | #include "skin_debug.h" |
Robert Bieber | 0a054b2 | 2010-06-01 16:44:52 +0000 | [diff] [blame] | 28 | #include "tag_table.h" |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 29 | |
| 30 | /* Global variables for debug output */ |
| 31 | int debug_indent_level = 0; |
| 32 | extern int skin_line; |
Robert Bieber | 3c4fb8a | 2010-07-18 00:59:02 +0000 | [diff] [blame] | 33 | extern char* skin_start; |
Jonathan Gordon | 9e07ef2 | 2011-11-15 14:11:08 +0000 | [diff] [blame] | 34 | extern char* skin_buffer; |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 35 | |
Robert Bieber | 0e44ce9 | 2010-06-07 20:29:46 +0000 | [diff] [blame] | 36 | /* Global error variables */ |
| 37 | int error_line; |
Robert Bieber | 3c4fb8a | 2010-07-18 00:59:02 +0000 | [diff] [blame] | 38 | int error_col; |
Nils Wallménius | 8be79a2 | 2010-07-31 16:33:34 +0000 | [diff] [blame] | 39 | const char *error_line_start; |
Robert Bieber | 0e44ce9 | 2010-06-07 20:29:46 +0000 | [diff] [blame] | 40 | char* error_message; |
| 41 | |
Jonathan Gordon | 9e07ef2 | 2011-11-15 14:11:08 +0000 | [diff] [blame] | 42 | |
| 43 | static inline struct skin_element* |
| 44 | get_child(OFFSETTYPE(struct skin_element**) children, int child) |
| 45 | { |
| 46 | struct skin_element **kids = SKINOFFSETTOPTR(skin_buffer, children); |
| 47 | return kids[child]; |
| 48 | } |
| 49 | |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 50 | /* Debugging functions */ |
Nils Wallménius | 804437a | 2010-07-31 16:30:22 +0000 | [diff] [blame] | 51 | void skin_error(enum skin_errorcode error, const char* cursor) |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 52 | { |
| 53 | |
Robert Bieber | 3c4fb8a | 2010-07-18 00:59:02 +0000 | [diff] [blame] | 54 | error_col = 0; |
| 55 | |
| 56 | while(cursor > skin_start && *cursor != '\n') |
| 57 | { |
| 58 | cursor--; |
| 59 | error_col++; |
| 60 | } |
Jonathan Gordon | 2d31d77 | 2010-07-29 12:37:48 +0000 | [diff] [blame] | 61 | error_line_start = cursor+1; |
Robert Bieber | 3c4fb8a | 2010-07-18 00:59:02 +0000 | [diff] [blame] | 62 | |
Robert Bieber | 0e44ce9 | 2010-06-07 20:29:46 +0000 | [diff] [blame] | 63 | error_line = skin_line; |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 64 | |
| 65 | switch(error) |
| 66 | { |
| 67 | case MEMORY_LIMIT_EXCEEDED: |
Jonathan Gordon | 21e89e8 | 2011-01-27 11:27:53 +0000 | [diff] [blame] | 68 | error_line_start = NULL; |
| 69 | printf("Error: Memory limit exceeded at Line %d\n", skin_line); |
Robert Bieber | 0e44ce9 | 2010-06-07 20:29:46 +0000 | [diff] [blame] | 70 | error_message = "Memory limit exceeded"; |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 71 | break; |
| 72 | case NEWLINE_EXPECTED: |
Robert Bieber | 0e44ce9 | 2010-06-07 20:29:46 +0000 | [diff] [blame] | 73 | error_message = "Newline expected"; |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 74 | break; |
| 75 | case ILLEGAL_TAG: |
Robert Bieber | 0e44ce9 | 2010-06-07 20:29:46 +0000 | [diff] [blame] | 76 | error_message = "Illegal tag"; |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 77 | break; |
| 78 | case ARGLIST_EXPECTED: |
Robert Bieber | 0e44ce9 | 2010-06-07 20:29:46 +0000 | [diff] [blame] | 79 | error_message = "Argument list expected"; |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 80 | break; |
| 81 | case TOO_MANY_ARGS: |
Robert Bieber | 0e44ce9 | 2010-06-07 20:29:46 +0000 | [diff] [blame] | 82 | error_message = "Too many arguments given"; |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 83 | break; |
| 84 | case DEFAULT_NOT_ALLOWED: |
Robert Bieber | 0e44ce9 | 2010-06-07 20:29:46 +0000 | [diff] [blame] | 85 | error_message = "Argument can not be set to default"; |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 86 | break; |
| 87 | case UNEXPECTED_NEWLINE: |
Robert Bieber | 0e44ce9 | 2010-06-07 20:29:46 +0000 | [diff] [blame] | 88 | error_message = "Unexpected newline"; |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 89 | break; |
| 90 | case INSUFFICIENT_ARGS: |
Robert Bieber | 0e44ce9 | 2010-06-07 20:29:46 +0000 | [diff] [blame] | 91 | error_message = "Not enough arguments"; |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 92 | break; |
| 93 | case INT_EXPECTED: |
Robert Bieber | 0e44ce9 | 2010-06-07 20:29:46 +0000 | [diff] [blame] | 94 | error_message = "Expected integer"; |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 95 | break; |
Robert Bieber | 15488a0 | 2010-07-15 06:24:11 +0000 | [diff] [blame] | 96 | case DECIMAL_EXPECTED: |
| 97 | error_message = "Expected decimal"; |
| 98 | break; |
Bertrik Sikken | fffbdcc | 2010-11-05 09:51:19 +0000 | [diff] [blame] | 99 | case SEPARATOR_EXPECTED: |
| 100 | error_message = "Expected argument separator"; |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 101 | break; |
| 102 | case CLOSE_EXPECTED: |
Robert Bieber | 0e44ce9 | 2010-06-07 20:29:46 +0000 | [diff] [blame] | 103 | error_message = "Expected list close"; |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 104 | break; |
| 105 | case MULTILINE_EXPECTED: |
Bertrik Sikken | fffbdcc | 2010-11-05 09:51:19 +0000 | [diff] [blame] | 106 | error_message = "Expected subline separator"; |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 107 | break; |
| 108 | }; |
| 109 | |
| 110 | } |
| 111 | |
Robert Bieber | 0e44ce9 | 2010-06-07 20:29:46 +0000 | [diff] [blame] | 112 | int skin_error_line() |
| 113 | { |
| 114 | return error_line; |
| 115 | } |
| 116 | |
Robert Bieber | 3c4fb8a | 2010-07-18 00:59:02 +0000 | [diff] [blame] | 117 | int skin_error_col() |
| 118 | { |
| 119 | return error_col; |
| 120 | } |
| 121 | |
Robert Bieber | 0e44ce9 | 2010-06-07 20:29:46 +0000 | [diff] [blame] | 122 | char* skin_error_message() |
| 123 | { |
| 124 | return error_message; |
| 125 | } |
| 126 | |
Robert Bieber | 594d734 | 2010-06-07 21:09:13 +0000 | [diff] [blame] | 127 | void skin_clear_errors() |
| 128 | { |
| 129 | error_line = 0; |
Robert Bieber | 3c4fb8a | 2010-07-18 00:59:02 +0000 | [diff] [blame] | 130 | error_col = 0; |
Robert Bieber | 594d734 | 2010-06-07 21:09:13 +0000 | [diff] [blame] | 131 | error_message = NULL; |
| 132 | } |
| 133 | |
Jonathan Gordon | 1e0a010 | 2010-08-03 12:14:50 +0000 | [diff] [blame] | 134 | #if !defined(ROCKBOX) || defined(__PCTOOL__) |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 135 | void skin_debug_tree(struct skin_element* root) |
| 136 | { |
| 137 | int i; |
Robert Bieber | 64321ad | 2010-06-10 21:02:44 +0000 | [diff] [blame] | 138 | char *text; |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 139 | |
| 140 | struct skin_element* current = root; |
| 141 | |
| 142 | while(current) |
| 143 | { |
| 144 | skin_debug_indent(); |
| 145 | |
| 146 | switch(current->type) |
| 147 | { |
Jonathan Gordon | 35b09cb | 2010-06-13 03:13:01 +0000 | [diff] [blame] | 148 | case UNKNOWN: |
Jonathan Gordon | 4d8430f | 2010-11-11 12:05:34 +0000 | [diff] [blame] | 149 | printf("* Unknown element.. error *\n"); |
Jonathan Gordon | 35b09cb | 2010-06-13 03:13:01 +0000 | [diff] [blame] | 150 | break; |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 151 | |
Robert Bieber | d1659d6 | 2010-06-01 07:11:23 +0000 | [diff] [blame] | 152 | case VIEWPORT: |
Jonathan Gordon | 4d8430f | 2010-11-11 12:05:34 +0000 | [diff] [blame] | 153 | printf("{ Viewport \n"); |
Robert Bieber | d1659d6 | 2010-06-01 07:11:23 +0000 | [diff] [blame] | 154 | |
| 155 | debug_indent_level++; |
Jonathan Gordon | 9e07ef2 | 2011-11-15 14:11:08 +0000 | [diff] [blame] | 156 | skin_debug_tree(get_child(current->children, 0)); |
Robert Bieber | d1659d6 | 2010-06-01 07:11:23 +0000 | [diff] [blame] | 157 | debug_indent_level--; |
| 158 | |
Jonathan Gordon | 4d8430f | 2010-11-11 12:05:34 +0000 | [diff] [blame] | 159 | printf("}"); |
Robert Bieber | d1659d6 | 2010-06-01 07:11:23 +0000 | [diff] [blame] | 160 | break; |
| 161 | |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 162 | case TEXT: |
Jonathan Gordon | 9e07ef2 | 2011-11-15 14:11:08 +0000 | [diff] [blame] | 163 | text = SKINOFFSETTOPTR(skin_buffer, current->data); |
Jonathan Gordon | 4d8430f | 2010-11-11 12:05:34 +0000 | [diff] [blame] | 164 | printf("* Plain text on line %d: \"%s\"\n", current->line, text); |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 165 | break; |
| 166 | |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 167 | case COMMENT: |
Jonathan Gordon | 4d8430f | 2010-11-11 12:05:34 +0000 | [diff] [blame] | 168 | printf("# Comment on line %d\n ", current->line); |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 169 | break; |
| 170 | |
| 171 | case TAG: |
Jonathan Gordon | 4d8430f | 2010-11-11 12:05:34 +0000 | [diff] [blame] | 172 | if (current->params_count) |
| 173 | { |
| 174 | printf("( %%%s tag on line %d with %d arguments\n", |
| 175 | current->tag->name, |
| 176 | current->line, current->params_count); |
| 177 | debug_indent_level++; |
Jonathan Gordon | 9e07ef2 | 2011-11-15 14:11:08 +0000 | [diff] [blame] | 178 | skin_debug_params(current->params_count, SKINOFFSETTOPTR(skin_buffer, current->params)); |
Jonathan Gordon | 4d8430f | 2010-11-11 12:05:34 +0000 | [diff] [blame] | 179 | debug_indent_level--; |
| 180 | skin_debug_indent(); |
| 181 | printf(")\n"); |
| 182 | } |
| 183 | else |
| 184 | { |
| 185 | printf("[ %%%s tag on line %d ]\n", |
| 186 | current->tag->name, current->line); |
| 187 | } |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 188 | |
| 189 | break; |
| 190 | |
Jonathan Gordon | dc34785 | 2010-07-04 02:04:14 +0000 | [diff] [blame] | 191 | case LINE_ALTERNATOR: |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 192 | printf("[ Alternator on line %d with %d sublines \n", current->line, |
| 193 | current->children_count); |
| 194 | debug_indent_level++; |
| 195 | for(i = 0; i < current->children_count; i++) |
| 196 | { |
Jonathan Gordon | 9e07ef2 | 2011-11-15 14:11:08 +0000 | [diff] [blame] | 197 | skin_debug_tree(get_child(current->children, i)); |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 198 | } |
| 199 | debug_indent_level--; |
Robert Bieber | 8ea056d | 2010-05-27 19:57:15 +0000 | [diff] [blame] | 200 | |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 201 | skin_debug_indent(); |
| 202 | printf("]\n"); |
| 203 | break; |
| 204 | |
| 205 | case CONDITIONAL: |
Jonathan Gordon | 4d8430f | 2010-11-11 12:05:34 +0000 | [diff] [blame] | 206 | printf("< Conditional tag %%?%s on line %d with %d enumerations \n", |
| 207 | current->tag->name, current->line, current->children_count); |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 208 | debug_indent_level++; |
| 209 | |
Jonathan Gordon | 4d8430f | 2010-11-11 12:05:34 +0000 | [diff] [blame] | 210 | for(i = 0; i < current->children_count; i++) |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 211 | { |
| 212 | skin_debug_indent(); |
Jonathan Gordon | 4d8430f | 2010-11-11 12:05:34 +0000 | [diff] [blame] | 213 | printf("[ Enumeration %d\n", i); |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 214 | debug_indent_level++; |
Jonathan Gordon | 9e07ef2 | 2011-11-15 14:11:08 +0000 | [diff] [blame] | 215 | skin_debug_tree(get_child(current->children, i)); |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 216 | debug_indent_level--; |
| 217 | skin_debug_indent(); |
| 218 | printf("]\n"); |
| 219 | } |
| 220 | |
| 221 | debug_indent_level--; |
| 222 | skin_debug_indent(); |
Jonathan Gordon | 4d8430f | 2010-11-11 12:05:34 +0000 | [diff] [blame] | 223 | printf(">\n"); |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 224 | |
| 225 | |
| 226 | break; |
| 227 | |
Robert Bieber | 8ea056d | 2010-05-27 19:57:15 +0000 | [diff] [blame] | 228 | case LINE: |
| 229 | printf("[ Logical line on line %d\n", current->line); |
| 230 | |
| 231 | debug_indent_level++; |
Jonathan Gordon | 1e0a010 | 2010-08-03 12:14:50 +0000 | [diff] [blame] | 232 | if (current->children) |
Jonathan Gordon | 9e07ef2 | 2011-11-15 14:11:08 +0000 | [diff] [blame] | 233 | skin_debug_tree(get_child(current->children, 0)); |
Robert Bieber | 8ea056d | 2010-05-27 19:57:15 +0000 | [diff] [blame] | 234 | debug_indent_level--; |
| 235 | |
| 236 | skin_debug_indent(); |
| 237 | printf("]\n"); |
| 238 | break; |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 239 | } |
| 240 | |
Jonathan Gordon | 9e07ef2 | 2011-11-15 14:11:08 +0000 | [diff] [blame] | 241 | current = SKINOFFSETTOPTR(skin_buffer, current->next); |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | } |
| 245 | |
| 246 | void skin_debug_params(int count, struct skin_tag_parameter params[]) |
| 247 | { |
| 248 | int i; |
| 249 | for(i = 0; i < count; i++) |
| 250 | { |
| 251 | |
| 252 | skin_debug_indent(); |
| 253 | switch(params[i].type) |
| 254 | { |
| 255 | case DEFAULT: |
Jonathan Gordon | 4d8430f | 2010-11-11 12:05:34 +0000 | [diff] [blame] | 256 | printf("-"); |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 257 | break; |
| 258 | |
| 259 | case STRING: |
Jonathan Gordon | 9e07ef2 | 2011-11-15 14:11:08 +0000 | [diff] [blame] | 260 | printf("string: \"%s\"", SKINOFFSETTOPTR(skin_buffer, params[i].data.text)); |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 261 | break; |
| 262 | |
Robert Bieber | 15488a0 | 2010-07-15 06:24:11 +0000 | [diff] [blame] | 263 | case INTEGER: |
Jonathan Gordon | 4d8430f | 2010-11-11 12:05:34 +0000 | [diff] [blame] | 264 | printf("integer: %d", params[i].data.number); |
Robert Bieber | 15488a0 | 2010-07-15 06:24:11 +0000 | [diff] [blame] | 265 | break; |
| 266 | |
| 267 | case DECIMAL: |
Jonathan Gordon | 4d8430f | 2010-11-11 12:05:34 +0000 | [diff] [blame] | 268 | printf("decimal: %d.%d", params[i].data.number/10, |
Robert Bieber | 15488a0 | 2010-07-15 06:24:11 +0000 | [diff] [blame] | 269 | params[i].data.number%10); |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 270 | break; |
| 271 | |
| 272 | case CODE: |
Jonathan Gordon | 4d8430f | 2010-11-11 12:05:34 +0000 | [diff] [blame] | 273 | printf("Skin Code: \n"); |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 274 | debug_indent_level++; |
Jonathan Gordon | 9e07ef2 | 2011-11-15 14:11:08 +0000 | [diff] [blame] | 275 | skin_debug_tree(SKINOFFSETTOPTR(skin_buffer, params[i].data.code)); |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 276 | debug_indent_level--; |
| 277 | skin_debug_indent(); |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 278 | break; |
| 279 | } |
| 280 | |
| 281 | printf("\n"); |
| 282 | |
| 283 | } |
| 284 | } |
| 285 | |
Jonathan Gordon | 5edae54 | 2012-03-15 23:26:07 +1100 | [diff] [blame] | 286 | void skin_debug_indent(void) |
Robert Bieber | d5b24dd | 2010-05-25 15:19:52 +0000 | [diff] [blame] | 287 | { |
| 288 | int i; |
| 289 | for(i = 0; i < debug_indent_level; i++) |
| 290 | printf(" "); |
| 291 | } |
Jonathan Gordon | 2d31d77 | 2010-07-29 12:37:48 +0000 | [diff] [blame] | 292 | |
Björn Stenberg | f1a144a | 2010-06-17 11:04:32 +0000 | [diff] [blame] | 293 | #endif |
Jonathan Gordon | 2d31d77 | 2010-07-29 12:37:48 +0000 | [diff] [blame] | 294 | |
| 295 | #define MIN(a,b) ((a<b)?(a):(b)) |
Jonathan Gordon | 5edae54 | 2012-03-15 23:26:07 +1100 | [diff] [blame] | 296 | void skin_error_format_message(void) |
Jonathan Gordon | 2d31d77 | 2010-07-29 12:37:48 +0000 | [diff] [blame] | 297 | { |
| 298 | int i; |
| 299 | char text[128]; |
Jonathan Gordon | f74a1aa | 2010-11-11 09:57:37 +0000 | [diff] [blame] | 300 | if (!error_line_start) |
| 301 | return; |
Jonathan Gordon | 2d31d77 | 2010-07-29 12:37:48 +0000 | [diff] [blame] | 302 | char* line_end = strchr(error_line_start, '\n'); |
| 303 | int len = MIN(line_end - error_line_start, 80); |
| 304 | if (!line_end) |
| 305 | len = strlen(error_line_start); |
| 306 | printf("Error on line %d.\n", error_line); |
| 307 | error_col--; |
| 308 | if (error_col <= 10) |
| 309 | { |
| 310 | strncpy(text, error_line_start, len); |
| 311 | text[len] = '\0'; |
| 312 | } |
| 313 | else |
| 314 | { |
| 315 | int j; |
| 316 | /* make it fit nicely.. "<start few chars>...<10 chars><error>" */ |
| 317 | strncpy(text, error_line_start, 6); |
| 318 | i = 5; |
| 319 | text[i++] = '.'; |
| 320 | text[i++] = '.'; |
| 321 | text[i++] = '.'; |
| 322 | for (j=error_col-10; error_line_start[j] && error_line_start[j] != '\n'; j++) |
| 323 | text[i++] = error_line_start[j]; |
| 324 | text[i] = '\0'; |
| 325 | error_col = 18; |
| 326 | } |
| 327 | printf("%s\n", text); |
| 328 | for (i=0; i<error_col; i++) |
| 329 | text[i] = ' '; |
| 330 | snprintf(&text[i],64, "^ \'%s\' Here", error_message); |
| 331 | printf("%s\n", text); |
| 332 | } |