/[qemacs]/qemacs/clang.c
ViewVC logotype

Diff of /qemacs/clang.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by chqrlie, Mon May 9 09:10:37 2005 UTC revision 1.6 by chqrlie, Wed May 11 15:12:14 2005 UTC
# Line 71  void c_colorize_line(unsigned int *buf, Line 71  void c_colorize_line(unsigned int *buf,
71      p = buf;      p = buf;
72      p_start = p;      p_start = p;
73      type_decl = 0;      type_decl = 0;
74      c = 0;      /* turn off stupid egcs-2.91.66 warning */      c = 0;      /* turn off stupid egcs-2.91.66 warning */
75    
76      /* if already in a state, go directly in the code parsing it */      /* if already in a state, go directly in the code parsing it */
77      switch(state) {      switch (state) {
78      case C_COMMENT:      case C_COMMENT:
79          goto parse_comment;          goto parse_comment;
80      case C_STRING:      case C_STRING:
# Line 86  void c_colorize_line(unsigned int *buf, Line 86  void c_colorize_line(unsigned int *buf,
86          break;          break;
87      }      }
88    
89      for(;;) {      for (;;) {
90          p_start = p;          p_start = p;
91          c = *p;          c = *p;
92          switch(c) {          switch (c) {
93          case '\n':          case '\n':
94              goto the_end;              goto the_end;
95          case '/':          case '/':
# Line 164  void c_colorize_line(unsigned int *buf, Line 164  void c_colorize_line(unsigned int *buf,
164                                    
165                  l = get_c_keyword(kbuf, sizeof(kbuf), &p);                  l = get_c_keyword(kbuf, sizeof(kbuf), &p);
166                  p1 = p;                  p1 = p;
167                  while (*p == ' ' || *p == '\t')                  while (*p == ' ' || *p == '\t')
168                      p++;                      p++;
169                  if (strfind(c_keywords, kbuf, 0)) {                  if (strfind(c_keywords, kbuf, 0)) {
170                      set_color(p_start, p1 - p_start, QE_STYLE_KEYWORD);                      set_color(p_start, p1 - p_start, QE_STYLE_KEYWORD);
171                  } else                  } else
172                  if (strfind(c_types, kbuf, 0)) {                  if (strfind(c_types, kbuf, 0)) {
173                      /* c type */                      /* c type */
174                      /* if not cast, assume type declaration */                      /* if not cast, assume type declaration */
175                      if (*p != ')') {                      if (*p != ')') {
# Line 216  static int find_indent1(EditState *s, un Line 216  static int find_indent1(EditState *s, un
216    
217      p = buf;      p = buf;
218      pos = 0;      pos = 0;
219      for(;;) {      for (;;) {
220          c = *p++ & CHAR_MASK;          c = *p++ & CHAR_MASK;
221          if (c == '\t')          if (c == '\t')
222              pos += s->tab_size - (pos % s->tab_size);              pos += s->tab_size - (pos % s->tab_size);
# Line 233  static int find_pos(EditState *s, unsign Line 233  static int find_pos(EditState *s, unsign
233      int pos, c, i;      int pos, c, i;
234    
235      pos = 0;      pos = 0;
236      for(i=0;i<size;i++) {      for (i = 0; i < size; i++) {
237          c = buf[i] & CHAR_MASK;          c = buf[i] & CHAR_MASK;
238          if (c == '\t')          if (c == '\t')
239              pos += s->tab_size - (pos % s->tab_size);              pos += s->tab_size - (pos % s->tab_size);
# Line 301  static void do_c_indent(EditState *s) Line 301  static void do_c_indent(EditState *s)
301      eoi_found = 0;      eoi_found = 0;
302      stack_ptr = 0;      stack_ptr = 0;
303      state = INDENT_NORM;      state = INDENT_NORM;
304      for(;;) {      for (;;) {
305          if (offsetl == 0)          if (offsetl == 0)
306              break;              break;
307          line_num--;          line_num--;
# Line 333  static void do_c_indent(EditState *s) Line 333  static void do_c_indent(EditState *s)
333                      goto check_instr;                      goto check_instr;
334                  }                  }
335              } else {              } else {
336                  switch(c) {                  switch (c) {
337                  case '}':                  case '}':
338                      if (stack_ptr >= MAX_STACK_SIZE)                      if (stack_ptr >= MAX_STACK_SIZE)
339                          return;                          return;
# Line 430  static void do_c_indent(EditState *s) Line 430  static void do_c_indent(EditState *s)
430      len = get_colorized_line(s, buf, MAX_BUF_SIZE - 1, offset, line_num1);      len = get_colorized_line(s, buf, MAX_BUF_SIZE - 1, offset, line_num1);
431    
432      if (stack_ptr == 0) {      if (stack_ptr == 0) {
433          if (!pos && lpos >= 0) {          if (!pos && lpos >= 0) {
434              /* start of instruction already found */              /* start of instruction already found */
435              pos = lpos;              pos = lpos;
436              if (!eoi_found)              if (!eoi_found)
437                  pos += s->indent_size;                  pos += s->indent_size;
438          }          }
439      }      }
440    
441      for(i=0;i<len;i++) {      for (i = 0; i < len; i++) {
442          c = buf[i];          c = buf[i];
443          style = c >> STYLE_SHIFT;          style = c >> STYLE_SHIFT;
444          /* if preprocess, no indent */          /* if preprocess, no indent */
# Line 463  static void do_c_indent(EditState *s) Line 463  static void do_c_indent(EditState *s)
463    
464      /* suppress leading spaces */      /* suppress leading spaces */
465      offset1 = offset;      offset1 = offset;
466      for(;;) {      for (;;) {
467          c = eb_nextc(s->b, offset1, &offset2);          c = eb_nextc(s->b, offset1, &offset2);
468          if (c != ' ' && c != '\t')          if (c != ' ' && c != '\t')
469              break;              break;
# Line 495  void do_c_indent_region(EditState *s) Line 495  void do_c_indent_region(EditState *s)
495          p2 = tmp;          p2 = tmp;
496      }      }
497    
498      for(;p1<=p2;p1++) {      for (;p1 <= p2; p1++) {
499          s->offset = eb_goto_pos(s->b, p1, 0);           s->offset = eb_goto_pos(s->b, p1, 0);
500          do_c_indent(s);          do_c_indent(s);
501      }      }
502  }  }
# Line 514  static int c_mode_probe(ModeProbeData *p Line 514  static int c_mode_probe(ModeProbeData *p
514      /* currently, only use the file extension */      /* currently, only use the file extension */
515      r = extension(p->filename);      r = extension(p->filename);
516      if (*r) {      if (*r) {
517          if (strfind("|c|e|h|js|cs|jav|java|cxx|cpp|", r + 1, 1))          if (strfind("|c|e|h|js|cs|jav|java|cxx|cpp|", r + 1, 1))
518              return 100;              return 100;
519      }      }
520      return 0;      return 0;
# Line 523  static int c_mode_probe(ModeProbeData *p Line 523  static int c_mode_probe(ModeProbeData *p
523  int c_mode_init(EditState *s, ModeSavedData *saved_data)  int c_mode_init(EditState *s, ModeSavedData *saved_data)
524  {  {
525      int ret;      int ret;
526    
527      ret = text_mode_init(s, saved_data);      ret = text_mode_init(s, saved_data);
528      if (ret)      if (ret)
529          return ret;          return ret;

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26