Mercurial > vim
changeset 18798:f0f9692d4487 v8.1.2387
patch 8.1.2387: using old C style comments
Commit: https://github.com/vim/vim/commit/2ab2e8608f9b2c85432715bb9a7f226fdbf8cd35
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Dec 4 21:24:53 2019 +0100
patch 8.1.2387: using old C style comments
Problem: Using old C style comments.
Solution: Use // comments where appropriate.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 04 Dec 2019 21:30:04 +0100 |
parents | 76af6d0ea316 |
children | d7d0942e231b |
files | src/hardcopy.c src/hashtab.c src/if_cscope.c src/if_lua.c src/if_mzsch.c src/if_perlsfio.c src/if_python.c src/if_python3.c src/if_ruby.c src/if_tcl.c src/if_xcmdsrv.c src/version.c |
diffstat | 12 files changed, 1350 insertions(+), 1336 deletions(-) [+] |
line wrap: on
line diff
--- a/src/hardcopy.c +++ b/src/hardcopy.c @@ -127,12 +127,12 @@ static option_table_T mbfont_opts[OPT_MB */ typedef struct { - int lead_spaces; /* remaining spaces for a TAB */ - int print_pos; /* virtual column for computing TABs */ - colnr_T column; /* byte column */ - linenr_T file_line; /* line nr in the buffer */ - long_u bytes_printed; /* bytes printed so far */ - int ff; /* seen form feed character */ + int lead_spaces; // remaining spaces for a TAB + int print_pos; // virtual column for computing TABs + colnr_T column; // byte column + linenr_T file_line; // line nr in the buffer + long_u bytes_printed; // bytes printed so far + int ff; // seen form feed character } prt_pos_T; static char *parse_list_options(char_u *option_str, option_table_T *table, int table_size); @@ -182,10 +182,10 @@ parse_list_options( char_u *colonp; char_u *commap; char_u *p; - int idx = 0; /* init for GCC */ + int idx = 0; // init for GCC int len; - /* Save the old values, so that they can be restored in case of an error. */ + // Save the old values, so that they can be restored in case of an error. old_opts = ALLOC_MULT(option_table_T, table_size); if (old_opts == NULL) return NULL; @@ -234,7 +234,7 @@ parse_list_options( break; } - table[idx].number = getdigits(&p); /*advances p*/ + table[idx].number = getdigits(&p); // advances p } table[idx].string = p; @@ -247,7 +247,7 @@ parse_list_options( if (ret != NULL) { - /* Restore old options in case of error */ + // Restore old options in case of error for (idx = 0; idx < table_size; ++idx) table[idx] = old_opts[idx]; } @@ -272,7 +272,7 @@ darken_rgb(long_u rgb) static long_u prt_get_term_color(int colorindex) { - /* TODO: Should check for xterm with 88 or 256 colors. */ + // TODO: Should check for xterm with 88 or 256 colors. if (t_colors > 8) return cterm_color_16[colorindex % 16]; return cterm_color_8[colorindex % 8]; @@ -328,7 +328,7 @@ prt_get_attr( pattr->fg_color = fg_color; pattr->bg_color = bg_color; } -#endif /* FEAT_SYN_HL */ +#endif // FEAT_SYN_HL static void prt_set_fg(long_u fg) @@ -381,20 +381,20 @@ prt_line_number( prt_set_font(psettings->number.bold, psettings->number.italic, psettings->number.underline); mch_print_start_line(TRUE, page_line); - /* Leave two spaces between the number and the text; depends on - * PRINT_NUMBER_WIDTH. */ + // Leave two spaces between the number and the text; depends on + // PRINT_NUMBER_WIDTH. sprintf((char *)tbuf, "%6ld", (long)lnum); for (i = 0; i < 6; i++) (void)mch_print_text_out(&tbuf[i], 1); #ifdef FEAT_SYN_HL if (psettings->do_syntax) - /* Set colors for next character. */ + // Set colors for next character. current_syn_id = -1; else #endif { - /* Set colors and font back to normal. */ + // Set colors and font back to normal. prt_set_fg(PRCOLOR_BLACK); prt_set_bg(PRCOLOR_WHITE); prt_set_font(FALSE, FALSE, FALSE); @@ -458,7 +458,7 @@ prt_header( char_u *p; int l; - /* Also use the space for the line number. */ + // Also use the space for the line number. if (prt_use_number()) width += PRINT_NUMBER_WIDTH; @@ -493,7 +493,7 @@ prt_header( p_header, use_sandbox, ' ', width, NULL, NULL); - /* Reset line numbers */ + // Reset line numbers curwin->w_cursor.lnum = tmp_lnum; curwin->w_topline = tmp_topline; curwin->w_botline = tmp_botline; @@ -506,7 +506,7 @@ prt_header( prt_set_bg(PRCOLOR_WHITE); prt_set_font(TRUE, FALSE, FALSE); - /* Use a negative line number to indicate printing in the top margin. */ + // Use a negative line number to indicate printing in the top margin. page_line = 0 - prt_header_height(); mch_print_start_line(TRUE, page_line); for (p = tbuf; *p != NUL; ) @@ -514,7 +514,7 @@ prt_header( if (mch_print_text_out(p, (l = (*mb_ptr2len)(p)))) { ++page_line; - if (page_line >= 0) /* out of room in header */ + if (page_line >= 0) // out of room in header break; mch_print_start_line(TRUE, page_line); } @@ -525,12 +525,12 @@ prt_header( #ifdef FEAT_SYN_HL if (psettings->do_syntax) - /* Set colors for next character. */ + // Set colors for next character. current_syn_id = -1; else #endif { - /* Set colors and font back to normal. */ + // Set colors and font back to normal. prt_set_fg(PRCOLOR_BLACK); prt_set_bg(PRCOLOR_WHITE); prt_set_font(FALSE, FALSE, FALSE); @@ -566,7 +566,7 @@ ex_hardcopy(exarg_T *eap) { char *errormsg = NULL; - /* Expand things like "%.ps". */ + // Expand things like "%.ps". if (expand_filename(eap, eap->cmdlinep, &errormsg) == FAIL) { if (errormsg != NULL) @@ -616,7 +616,7 @@ ex_hardcopy(exarg_T *eap) settings.do_syntax = settings.has_color; #endif - /* Set up printing attributes for line numbers */ + // Set up printing attributes for line numbers settings.number.fg_color = PRCOLOR_BLACK; settings.number.bg_color = PRCOLOR_WHITE; settings.number.bold = FALSE; @@ -649,7 +649,7 @@ ex_hardcopy(exarg_T *eap) goto print_fail_no_begin; } - /* Set colors and font to normal. */ + // Set colors and font to normal. curr_bg = (long_u)0xffffffffL; curr_fg = (long_u)0xffffffffL; curr_italic = MAYBE; @@ -677,8 +677,8 @@ ex_hardcopy(exarg_T *eap) collated_copies < settings.n_collated_copies; collated_copies++) { - prt_pos_T prtpos; /* current print position */ - prt_pos_T page_prtpos; /* print position at page start */ + prt_pos_T prtpos; // current print position + prt_pos_T page_prtpos; // print position at page start int side; vim_memset(&page_prtpos, 0, sizeof(prt_pos_T)); @@ -687,7 +687,7 @@ ex_hardcopy(exarg_T *eap) if (jobsplit && collated_copies > 0) { - /* Splitting jobs: Stop a previous job and start a new one. */ + // Splitting jobs: Stop a previous job and start a new one. mch_print_end(&settings); if (!mch_print_begin(&settings)) goto print_fail_no_begin; @@ -706,7 +706,7 @@ ex_hardcopy(exarg_T *eap) uncollated_copies < settings.n_uncollated_copies; uncollated_copies++) { - /* Set the print position to the start of this page. */ + // Set the print position to the start of this page. prtpos = page_prtpos; /* @@ -718,7 +718,7 @@ ex_hardcopy(exarg_T *eap) * Print one page. */ - /* Check for interrupt character every page. */ + // Check for interrupt character every page. ui_breakcheck(); if (got_int || settings.user_abort) goto print_fail; @@ -754,16 +754,16 @@ ex_hardcopy(exarg_T *eap) page_line, &prtpos); if (prtpos.column == 0) { - /* finished a file line */ + // finished a file line prtpos.bytes_printed += STRLEN(skipwhite(ml_get(prtpos.file_line))); if (++prtpos.file_line > eap->line2) - break; /* reached the end */ + break; // reached the end } else if (prtpos.ff) { - /* Line had a formfeed in it - start new page but - * stay on the current line */ + // Line had a formfeed in it - start new page but + // stay on the current line break; } } @@ -771,7 +771,7 @@ ex_hardcopy(exarg_T *eap) if (!mch_print_end_page()) goto print_fail; if (prtpos.file_line > eap->line2) - break; /* reached the end */ + break; // reached the end } /* @@ -789,7 +789,7 @@ ex_hardcopy(exarg_T *eap) if (settings.duplex && prtpos.file_line <= eap->line2) ++page_count; - /* Remember the position where the next page starts. */ + // Remember the position where the next page starts. page_prtpos = prtpos; } @@ -841,7 +841,7 @@ hardcopy_line( } else { - /* left over from wrap halfway a tab */ + // left over from wrap halfway a tab print_pos = ppos->print_pos; tab_spaces = ppos->lead_spaces; } @@ -868,7 +868,7 @@ hardcopy_line( id = syn_get_final_id(id); else id = 0; - /* Get the line again, a multi-line regexp may invalidate it. */ + // Get the line again, a multi-line regexp may invalidate it. line = ml_get(ppos->file_line); if (id != current_syn_id) @@ -903,7 +903,7 @@ hardcopy_line( if (need_break) break; } - /* Keep the TAB if we didn't finish it. */ + // Keep the TAB if we didn't finish it. if (need_break && tab_spaces > 0) break; } @@ -974,14 +974,14 @@ hardcopy_line( #define NUM_ELEMENTS(arr) (sizeof(arr)/sizeof((arr)[0])) -#define PRT_PS_DEFAULT_DPI (72) /* Default user space resolution */ +#define PRT_PS_DEFAULT_DPI (72) // Default user space resolution #define PRT_PS_DEFAULT_FONTSIZE (10) #define PRT_PS_DEFAULT_BUFFER_SIZE (80) struct prt_mediasize_S { char *name; - float width; /* width and height in points for portrait */ + float width; // width and height in points for portrait float height; }; @@ -998,14 +998,14 @@ static struct prt_mediasize_S prt_medias {"B5", 516.0, 729.0}, {"executive", 522.0, 756.0}, {"folio", 595.0, 935.0}, - {"ledger", 1224.0, 792.0}, /* Yes, it is wider than taller! */ + {"ledger", 1224.0, 792.0}, // Yes, it is wider than taller! {"legal", 612.0, 1008.0}, {"quarto", 610.0, 780.0}, {"statement", 396.0, 612.0}, {"tabloid", 792.0, 1224.0} }; -/* PS font names, must be in Roman, Bold, Italic, Bold-Italic order */ +// PS font names, must be in Roman, Bold, Italic, Bold-Italic order struct prt_ps_font_S { int wx; @@ -1021,7 +1021,7 @@ struct prt_ps_font_S #define PRT_PS_FONT_OBLIQUE (2) #define PRT_PS_FONT_BOLDOBLIQUE (3) -/* Standard font metrics for Courier family */ +// Standard font metrics for Courier family static struct prt_ps_font_S prt_ps_courier_font = { 600, @@ -1030,7 +1030,7 @@ static struct prt_ps_font_S prt_ps_couri {"Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique"} }; -/* Generic font metrics for multi-byte fonts */ +// Generic font metrics for multi-byte fonts static struct prt_ps_font_S prt_ps_mb_font = { 1000, @@ -1039,11 +1039,11 @@ static struct prt_ps_font_S prt_ps_mb_fo {NULL, NULL, NULL, NULL} }; -/* Pointer to current font set being used */ +// Pointer to current font set being used static struct prt_ps_font_S* prt_ps_font; -/* Structures to map user named encoding and mapping to PS equivalents for - * building CID font name */ +// Structures to map user named encoding and mapping to PS equivalents for +// building CID font name struct prt_ps_encoding_S { char *encoding; @@ -1068,7 +1068,7 @@ struct prt_ps_charset_S #define CS_KANJITALK6 (0x40) #define CS_KANJITALK7 (0x80) -/* Japanese encodings and charsets */ +// Japanese encodings and charsets static struct prt_ps_encoding_S j_encodings[] = { {"iso-2022-jp", NULL, (CS_JIS_C_1978|CS_JIS_X_1983|CS_JIS_X_1990| @@ -1100,7 +1100,7 @@ static struct prt_ps_charset_S j_charset #define CS_GBK (0x20) #define CS_SC_ISO10646 (0x40) -/* Simplified Chinese encodings and charsets */ +// Simplified Chinese encodings and charsets static struct prt_ps_encoding_S sc_encodings[] = { {"iso-2022", NULL, (CS_GB_2312_80|CS_GBT_12345_90)}, @@ -1136,7 +1136,7 @@ static struct prt_ps_charset_S sc_charse #define CS_DLHKS (0x800) #define CS_TC_ISO10646 (0x1000) -/* Traditional Chinese encodings and charsets */ +// Traditional Chinese encodings and charsets static struct prt_ps_encoding_S tc_encodings[] = { {"iso-2022", NULL, (CS_CNS_PLANE_1|CS_CNS_PLANE_2)}, @@ -1173,7 +1173,7 @@ static struct prt_ps_charset_S tc_charse #define CS_KR_X_1992_MS (0x04) #define CS_KR_ISO10646 (0x08) -/* Korean encodings and charsets */ +// Korean encodings and charsets static struct prt_ps_encoding_S k_encodings[] = { {"iso-2022-kr", NULL, CS_KR_X_1992}, @@ -1196,7 +1196,7 @@ static struct prt_ps_charset_S k_charset {"ISO10646", "UniKS", CS_KR_ISO10646} }; -/* Collections of encodings and charsets for multi-byte printing */ +// Collections of encodings and charsets for multi-byte printing struct prt_ps_mbfont_S { int num_encodings; @@ -1252,27 +1252,25 @@ struct prt_ps_resource_S char_u version[256]; }; -/* Types of PS resource file currently used */ +// Types of PS resource file currently used #define PRT_RESOURCE_TYPE_PROCSET (0) #define PRT_RESOURCE_TYPE_ENCODING (1) #define PRT_RESOURCE_TYPE_CMAP (2) -/* The PS prolog file version number has to match - if the prolog file is - * updated, increment the number in the file and here. Version checking was - * added as of VIM 6.2. - * The CID prolog file version number behaves as per PS prolog. - * Table of VIM and prolog versions: - * - * VIM Prolog CIDProlog - * 6.2 1.3 - * 7.0 1.4 1.0 - */ +// The PS prolog file version number has to match - if the prolog file is +// updated, increment the number in the file and here. Version checking was +// added as of VIM 6.2. +// The CID prolog file version number behaves as per PS prolog. +// Table of VIM and prolog versions: +// +// VIM Prolog CIDProlog +// 6.2 1.3 +// 7.0 1.4 1.0 #define PRT_PROLOG_VERSION ((char_u *)"1.4") #define PRT_CID_PROLOG_VERSION ((char_u *)"1.0") -/* String versions of PS resource types - indexed by constants above so don't - * re-order! - */ +// String versions of PS resource types - indexed by constants above so don't +// re-order! static char *prt_resource_types[] = { "procset", @@ -1280,7 +1278,7 @@ static char *prt_resource_types[] = "cmap" }; -/* Strings to look for in a PS resource file */ +// Strings to look for in a PS resource file #define PRT_RESOURCE_HEADER "%!PS-Adobe-" #define PRT_RESOURCE_RESOURCE "Resource-" #define PRT_RESOURCE_PROCSET "ProcSet" @@ -1288,8 +1286,8 @@ static char *prt_resource_types[] = #define PRT_RESOURCE_CMAP "CMap" -/* Data for table based DSC comment recognition, easy to extend if VIM needs to - * read more comments. */ +// Data for table based DSC comment recognition, easy to extend if VIM needs to +// read more comments. #define PRT_DSC_MISC_TYPE (-1) #define PRT_DSC_TITLE_TYPE (1) #define PRT_DSC_VERSION_TYPE (2) @@ -1545,19 +1543,19 @@ prt_write_real(double val, int prec) int fraction; prt_real_bits(val, prec, &integer, &fraction); - /* Emit integer part */ + // Emit integer part sprintf((char *)prt_line_buffer, "%d", integer); prt_write_file(prt_line_buffer); - /* Only emit fraction if necessary */ + // Only emit fraction if necessary if (fraction != 0) { - /* Remove any trailing zeros */ + // Remove any trailing zeros while ((fraction % 10) == 0) { prec--; fraction /= 10; } - /* Emit fraction left padded with zeros */ + // Emit fraction left padded with zeros sprintf((char *)prt_line_buffer, ".%0*d", prec, fraction); prt_write_file(prt_line_buffer); } @@ -1579,7 +1577,7 @@ prt_def_var(char *name, double value, in prt_write_file(prt_line_buffer); } -/* Convert size from font space to user space at current font scale */ +// Convert size from font space to user space at current font scale #define PRT_PS_FONT_TO_USER(scale, size) ((size) * ((scale)/1000.0)) static void @@ -1587,7 +1585,7 @@ prt_flush_buffer(void) { if (prt_ps_buffer.ga_len > 0) { - /* Any background color must be drawn first */ + // Any background color must be drawn first if (prt_do_bgcol && (prt_new_bgcol != PRCOLOR_WHITE)) { int r, g, b; @@ -1600,11 +1598,11 @@ prt_flush_buffer(void) prt_do_moveto = FALSE; } - /* Size of rect of background color on which text is printed */ + // Size of rect of background color on which text is printed prt_write_real(prt_text_run, 2); prt_write_real(prt_line_height, 2); - /* Lastly add the color of the background */ + // Lastly add the color of the background r = ((unsigned)prt_new_bgcol & 0xff0000) >> 16; g = ((unsigned)prt_new_bgcol & 0xff00) >> 8; b = prt_new_bgcol & 0xff; @@ -1613,9 +1611,8 @@ prt_flush_buffer(void) prt_write_real(b / 255.0, 3); prt_write_string("bg\n"); } - /* Draw underlines before the text as it makes it slightly easier to - * find the starting point. - */ + // Draw underlines before the text as it makes it slightly easier to + // find the starting point. if (prt_do_underline) { if (prt_do_moveto) @@ -1626,13 +1623,13 @@ prt_flush_buffer(void) prt_do_moveto = FALSE; } - /* Underline length of text run */ + // Underline length of text run prt_write_real(prt_text_run, 2); prt_write_string("ul\n"); } - /* Draw the text - * Note: we write text out raw - EBCDIC conversion is handled in the - * PostScript world via the font encoding vector. */ + // Draw the text + // Note: we write text out raw - EBCDIC conversion is handled in the + // PostScript world via the font encoding vector. if (prt_out_mbyte) prt_write_string("<"); else @@ -1642,16 +1639,16 @@ prt_flush_buffer(void) prt_write_string(">"); else prt_write_string(")"); - /* Add a moveto if need be and use the appropriate show procedure */ + // Add a moveto if need be and use the appropriate show procedure if (prt_do_moveto) { prt_write_real(prt_pos_x_moveto, 2); prt_write_real(prt_pos_y_moveto, 2); - /* moveto and a show */ + // moveto and a show prt_write_string("ms\n"); prt_do_moveto = FALSE; } - else /* Simple show */ + else // Simple show prt_write_string("s\n"); ga_clear(&prt_ps_buffer); @@ -1682,7 +1679,7 @@ prt_find_resource(char *name, struct prt return FALSE; vim_strncpy(resource->name, (char_u *)name, 63); - /* Look for named resource file in runtimepath */ + // Look for named resource file in runtimepath STRCPY(buffer, "print"); add_pathsep(buffer); vim_strcat(buffer, (char_u *)name, MAXPATHL); @@ -1695,12 +1692,12 @@ prt_find_resource(char *name, struct prt return retval; } -/* PS CR and LF characters have platform independent values */ +// PS CR and LF characters have platform independent values #define PSLF (0x0a) #define PSCR (0x0d) -/* Static buffer to read initial comments in a resource file, some can have a - * couple of KB of comments! */ +// Static buffer to read initial comments in a resource file, some can have a +// couple of KB of comments! #define PRT_FILE_BUFFER_LEN (2048) struct prt_resfile_buffer_S { @@ -1717,7 +1714,7 @@ prt_resfile_next_line(void) { int idx; - /* Move to start of next line and then find end of line */ + // Move to start of next line and then find end of line idx = prt_resfile.line_end + 1; while (idx < prt_resfile.len) { @@ -1741,7 +1738,7 @@ prt_resfile_next_line(void) static int prt_resfile_strncmp(int offset, char *string, int len) { - /* Force not equal if string is longer than remainder of line */ + // Force not equal if string is longer than remainder of line if (len > (prt_resfile.line_end - (prt_resfile.line_start + offset))) return 1; @@ -1779,23 +1776,23 @@ prt_resfile_skip_ws(int offset) return -1; } -/* prt_next_dsc() - returns detail on next DSC comment line found. Returns true - * if a DSC comment is found, else false */ +// prt_next_dsc() - returns detail on next DSC comment line found. Returns true +// if a DSC comment is found, else false static int prt_next_dsc(struct prt_dsc_line_S *p_dsc_line) { int comment; int offset; - /* Move to start of next line */ + // Move to start of next line if (!prt_resfile_next_line()) return FALSE; - /* DSC comments always start %% */ + // DSC comments always start %% if (prt_resfile_strncmp(0, "%%", 2) != 0) return FALSE; - /* Find type of DSC comment */ + // Find type of DSC comment for (comment = 0; comment < (int)NUM_ELEMENTS(prt_dsc_table); comment++) if (prt_resfile_strncmp(0, prt_dsc_table[comment].string, prt_dsc_table[comment].len) == 0) @@ -1803,20 +1800,20 @@ prt_next_dsc(struct prt_dsc_line_S *p_ds if (comment != NUM_ELEMENTS(prt_dsc_table)) { - /* Return type of comment */ + // Return type of comment p_dsc_line->type = prt_dsc_table[comment].type; offset = prt_dsc_table[comment].len; } else { - /* Unrecognised DSC comment, skip to ws after comment leader */ + // Unrecognised DSC comment, skip to ws after comment leader p_dsc_line->type = PRT_DSC_MISC_TYPE; offset = prt_resfile_skip_nonws(0); if (offset == -1) return FALSE; } - /* Skip ws to comment value */ + // Skip ws to comment value offset = prt_resfile_skip_ws(offset); if (offset == -1) return FALSE; @@ -1827,7 +1824,8 @@ prt_next_dsc(struct prt_dsc_line_S *p_ds return TRUE; } -/* Improved hand crafted parser to get the type, title, and version number of a +/* + * Improved hand crafted parser to get the type, title, and version number of a * PS resource file so the file details can be added to the DSC header comments. */ static int @@ -1848,7 +1846,7 @@ prt_open_resource(struct prt_ps_resource } vim_memset(prt_resfile.buffer, NUL, PRT_FILE_BUFFER_LEN); - /* Parse first line to ensure valid resource file */ + // Parse first line to ensure valid resource file prt_resfile.len = (int)fread((char *)prt_resfile.buffer, sizeof(char_u), PRT_FILE_BUFFER_LEN, fd_resource); if (ferror(fd_resource)) @@ -1875,7 +1873,7 @@ prt_open_resource(struct prt_ps_resource return FALSE; } - /* Skip over any version numbers and following ws */ + // Skip over any version numbers and following ws offset += (int)STRLEN(PRT_RESOURCE_HEADER); offset = prt_resfile_skip_nonws(offset); if (offset == -1) @@ -1893,7 +1891,7 @@ prt_open_resource(struct prt_ps_resource } offset += (int)STRLEN(PRT_RESOURCE_RESOURCE); - /* Decide type of resource in the file */ + // Decide type of resource in the file if (prt_resfile_strncmp(offset, PRT_RESOURCE_PROCSET, (int)STRLEN(PRT_RESOURCE_PROCSET)) == 0) resource->type = PRT_RESOURCE_TYPE_PROCSET; @@ -1910,7 +1908,7 @@ prt_open_resource(struct prt_ps_resource return FALSE; } - /* Look for title and version of resource */ + // Look for title and version of resource resource->title[0] = '\0'; resource->version[0] = '\0'; seen_title = FALSE; @@ -1935,12 +1933,12 @@ prt_open_resource(struct prt_ps_resource break; case PRT_DSC_ENDCOMMENTS_TYPE: - /* Wont find title or resource after this comment, stop searching */ + // Wont find title or resource after this comment, stop searching seen_all = TRUE; break; case PRT_DSC_MISC_TYPE: - /* Not interested in whatever comment this line had */ + // Not interested in whatever comment this line had break; } } @@ -1958,7 +1956,7 @@ prt_open_resource(struct prt_ps_resource static int prt_check_resource(struct prt_ps_resource_S *resource, char_u *version) { - /* Version number m.n should match, the revision number does not matter */ + // Version number m.n should match, the revision number does not matter if (STRNCMP(resource->version, version, STRLEN(version))) { semsg(_("E621: \"%s\" resource file has wrong version"), @@ -1966,7 +1964,7 @@ prt_check_resource(struct prt_ps_resourc return FALSE; } - /* Other checks to be added as needed */ + // Other checks to be added as needed return TRUE; } @@ -1995,7 +1993,7 @@ prt_dsc_textline(char *comment, char *te static void prt_dsc_text(char *comment, char *text) { - /* TODO - should scan 'text' for any chars needing escaping! */ + // TODO - should scan 'text' for any chars needing escaping! vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer), "%%%%%s: (%s)\n", comment, text); prt_write_file(prt_line_buffer); @@ -2023,7 +2021,7 @@ prt_dsc_ints(char *comment, int count, i static void prt_dsc_resources( - char *comment, /* if NULL add to previous */ + char *comment, // if NULL add to previous char *type, char *string) { @@ -2060,9 +2058,8 @@ prt_dsc_requirements( int color, int num_copies) { - /* Only output the comment if we need to. - * Note: tumble is ignored if we are not duplexing - */ + // Only output the comment if we need to. + // Note: tumble is ignored if we are not duplexing if (!(duplex || collate || color || (num_copies > 1))) return; @@ -2082,7 +2079,7 @@ prt_dsc_requirements( if (num_copies > 1) { prt_write_string(" numcopies("); - /* Note: no space wanted so don't use prt_write_int() */ + // Note: no space wanted so don't use prt_write_int() sprintf((char *)prt_line_buffer, "%d", num_copies); prt_write_file(prt_line_buffer); prt_write_string(")"); @@ -2124,10 +2121,9 @@ mch_print_cleanup(void) { int i; - /* Free off all CID font names created, but first clear duplicate - * pointers to the same string (when the same font is used for more than - * one style). - */ + // Free off all CID font names created, but first clear duplicate + // pointers to the same string (when the same font is used for more than + // one style). for (i = PRT_PS_FONT_ROMAN; i <= PRT_PS_FONT_BOLDOBLIQUE; i++) { if (prt_ps_mb_font.ps_fontname[i] != NULL) @@ -2218,9 +2214,8 @@ prt_get_cpl(void) if (prt_use_number()) { prt_number_width = PRINT_NUMBER_WIDTH * prt_char_width; - /* If we are outputting multi-byte characters then line numbers will be - * printed with half width characters - */ + // If we are outputting multi-byte characters then line numbers will be + // printed with half width characters if (prt_out_mbyte) prt_number_width /= 2; prt_left_margin += prt_number_width; @@ -2267,13 +2262,13 @@ prt_get_lpp(void) prt_ps_font->bbox_min_y)) / 2); } - /* Get height for topmost line based on background rect offset. */ + // Get height for topmost line based on background rect offset. prt_first_line_height = prt_line_height + prt_bgcol_offset; - /* Calculate lpp */ + // Calculate lpp lpp = (int)((prt_top_margin - prt_bottom_margin) / prt_line_height); - /* Adjust top margin if there is a header */ + // Adjust top margin if there is a header prt_top_margin -= prt_line_height * prt_header_height(); return lpp - prt_header_height(); @@ -2290,7 +2285,7 @@ prt_match_encoding( struct prt_ps_encoding_S *p_mbenc; *pp_mbenc = NULL; - /* Look for recognised encoding */ + // Look for recognised encoding enc_len = (int)STRLEN(p_encoding); p_mbenc = p_cmap->encodings; for (mbenc = 0; mbenc < p_cmap->num_encodings; mbenc++) @@ -2315,7 +2310,7 @@ prt_match_charset( int char_len; struct prt_ps_charset_S *p_mbchar; - /* Look for recognised character set, using default if one is not given */ + // Look for recognised character set, using default if one is not given if (*p_charset == NUL) p_charset = p_cmap->defcs; char_len = (int)STRLEN(p_charset); @@ -2379,10 +2374,10 @@ mch_print_init( if (*p_encoding == NUL) p_encoding = enc_skip(p_enc); - /* Look for a multi-byte font that matches the encoding and character set. - * Only look if multi-byte character set is defined, or using multi-byte - * encoding other than Unicode. This is because a Unicode encoding does not - * uniquely identify a CJK character set to use. */ + // Look for a multi-byte font that matches the encoding and character set. + // Only look if multi-byte character set is defined, or using multi-byte + // encoding other than Unicode. This is because a Unicode encoding does not + // uniquely identify a CJK character set to use. p_mbenc = NULL; props = enc_canon_props(p_encoding); if (!(props & ENC_8BIT) && ((*p_pmcs != NUL) || !(props & ENC_UNICODE))) @@ -2404,7 +2399,7 @@ mch_print_init( break; } - /* Use first encoding matched if no charset matched */ + // Use first encoding matched if no charset matched if (p_mbchar == NULL && p_mbenc_first != NULL) { p_mbenc = p_mbenc_first; @@ -2415,20 +2410,20 @@ mch_print_init( prt_out_mbyte = (p_mbenc != NULL); if (prt_out_mbyte) { - /* Build CMap name - will be same for all multi-byte fonts used */ + // Build CMap name - will be same for all multi-byte fonts used prt_cmap[0] = NUL; prt_custom_cmap = (p_mbchar == NULL); if (!prt_custom_cmap) { - /* Check encoding and character set are compatible */ + // Check encoding and character set are compatible if ((p_mbenc->needs_charset & p_mbchar->has_charset) == 0) { emsg(_("E673: Incompatible multi-byte encoding and character set.")); return FALSE; } - /* Add charset name if not empty */ + // Add charset name if not empty if (p_mbchar->cmap_charset != NULL) { vim_strncpy((char_u *)prt_cmap, @@ -2438,7 +2433,7 @@ mch_print_init( } else { - /* Add custom CMap character set name */ + // Add custom CMap character set name if (*p_pmcs == NUL) { emsg(_("E674: printmbcharset cannot be empty with multi-byte encoding.")); @@ -2448,7 +2443,7 @@ mch_print_init( STRCAT(prt_cmap, "-"); } - /* CMap name ends with (optional) encoding name and -H for horizontal */ + // CMap name ends with (optional) encoding name and -H for horizontal if (p_mbenc->cmap_encoding != NULL && STRLEN(prt_cmap) + STRLEN(p_mbenc->cmap_encoding) + 3 < sizeof(prt_cmap)) { @@ -2463,7 +2458,7 @@ mch_print_init( return FALSE; } - /* Derive CID font names with fallbacks if not defined */ + // Derive CID font names with fallbacks if not defined if (!prt_build_cid_fontname(PRT_PS_FONT_ROMAN, mbfont_opts[OPT_MBFONT_REGULAR].string, mbfont_opts[OPT_MBFONT_REGULAR].strlen)) @@ -2484,13 +2479,13 @@ mch_print_init( mbfont_opts[OPT_MBFONT_BOLDOBLIQUE].strlen)) return FALSE; - /* Check if need to use Courier for ASCII code range, and if so pick up - * the encoding to use */ + // Check if need to use Courier for ASCII code range, and if so pick up + // the encoding to use prt_use_courier = mbfont_opts[OPT_MBFONT_USECOURIER].present && (TOLOWER_ASC(mbfont_opts[OPT_MBFONT_USECOURIER].string[0]) == 'y'); if (prt_use_courier) { - /* Use national ASCII variant unless ASCII wanted */ + // Use national ASCII variant unless ASCII wanted if (mbfont_opts[OPT_MBFONT_ASCII].present && (TOLOWER_ASC(mbfont_opts[OPT_MBFONT_ASCII].string[0]) == 'y')) prt_ascii_encoding = "ascii"; @@ -2575,7 +2570,7 @@ mch_print_init( psettings->chars_per_line = prt_get_cpl(); psettings->lines_per_page = prt_get_lpp(); - /* Catch margin settings that leave no space for output! */ + // Catch margin settings that leave no space for output! if (psettings->chars_per_line <= 0 || psettings->lines_per_page <= 0) return FAIL; @@ -2592,14 +2587,13 @@ mch_print_init( || TOLOWER_ASC(printer_opts[OPT_PRINT_COLLATE].string[0]) == 'y'); if (prt_collate) { - /* TODO: Get number of collated copies wanted. */ + // TODO: Get number of collated copies wanted. psettings->n_collated_copies = 1; } else { - /* TODO: Get number of uncollated copies wanted and update the cached - * count. - */ + // TODO: Get number of uncollated copies wanted and update the cached + // count. prt_num_copies = 1; } @@ -2624,10 +2618,10 @@ mch_print_init( prt_tumble = TRUE; } - /* For now user abort not supported */ + // For now user abort not supported psettings->user_abort = 0; - /* If the user didn't specify a file name, use a temp file. */ + // If the user didn't specify a file name, use a temp file. if (psettings->outfile == NULL) { prt_ps_file_name = vim_tempname('p', TRUE); @@ -2757,26 +2751,25 @@ mch_print_begin(prt_settings_T *psetting STRCPY(buffer, "Unknown"); prt_dsc_textline("For", buffer); prt_dsc_textline("Creator", VIM_VERSION_LONG); - /* Note: to ensure Clean8bit I don't think we can use LC_TIME */ + // Note: to ensure Clean8bit I don't think we can use LC_TIME prt_dsc_textline("CreationDate", get_ctime(time(NULL), FALSE)); prt_dsc_textline("DocumentData", "Clean8Bit"); prt_dsc_textline("Orientation", "Portrait"); prt_dsc_atend("Pages"); prt_dsc_textline("PageOrder", "Ascend"); - /* The bbox does not change with orientation - it is always in the default - * user coordinate system! We have to recalculate right and bottom - * coordinates based on the font metrics for the bbox to be accurate. */ + // The bbox does not change with orientation - it is always in the default + // user coordinate system! We have to recalculate right and bottom + // coordinates based on the font metrics for the bbox to be accurate. prt_page_margins(prt_mediasize[prt_media].width, prt_mediasize[prt_media].height, &left, &right, &top, &bottom); bbox[0] = (int)left; if (prt_portrait) { - /* In portrait printing the fixed point is the top left corner so we - * derive the bbox from that point. We have the expected cpl chars - * across the media and lpp lines down the media. - */ + // In portrait printing the fixed point is the top left corner so we + // derive the bbox from that point. We have the expected cpl chars + // across the media and lpp lines down the media. bbox[1] = (int)(top - (psettings->lines_per_page + prt_header_height()) * prt_line_height); bbox[2] = (int)(left + psettings->chars_per_line * prt_char_width @@ -2785,10 +2778,9 @@ mch_print_begin(prt_settings_T *psetting } else { - /* In landscape printing the fixed point is the bottom left corner so we - * derive the bbox from that point. We have lpp chars across the media - * and cpl lines up the media. - */ + // In landscape printing the fixed point is the bottom left corner so we + // derive the bbox from that point. We have lpp chars across the media + // and cpl lines up the media. bbox[1] = (int)bottom; bbox[2] = (int)(left + ((psettings->lines_per_page + prt_header_height()) * prt_line_height) + 0.5); @@ -2796,12 +2788,12 @@ mch_print_begin(prt_settings_T *psetting + 0.5); } prt_dsc_ints("BoundingBox", 4, bbox); - /* The media width and height does not change with landscape printing! */ + // The media width and height does not change with landscape printing! prt_dsc_docmedia(prt_mediasize[prt_media].name, prt_mediasize[prt_media].width, prt_mediasize[prt_media].height, (double)0, NULL, NULL); - /* Define fonts needed */ + // Define fonts needed if (!prt_out_mbyte || prt_use_courier) prt_dsc_font_resource("DocumentNeededResources", &prt_ps_courier_font); if (prt_out_mbyte) @@ -2812,7 +2804,7 @@ mch_print_begin(prt_settings_T *psetting prt_dsc_resources(NULL, "cmap", prt_cmap); } - /* Search for external resources VIM supplies */ + // Search for external resources VIM supplies if (!prt_find_resource("prolog", res_prolog)) { emsg(_("E456: Can't find PostScript resource file \"prolog.ps\"")); @@ -2824,7 +2816,7 @@ mch_print_begin(prt_settings_T *psetting goto theend; if (prt_out_mbyte) { - /* Look for required version of multi-byte printing procset */ + // Look for required version of multi-byte printing procset if (!prt_find_resource("cidfont", res_cidfont)) { emsg(_("E456: Can't find PostScript resource file \"cidfont.ps\"")); @@ -2836,27 +2828,26 @@ mch_print_begin(prt_settings_T *psetting goto theend; } - /* Find an encoding to use for printing. - * Check 'printencoding'. If not set or not found, then use 'encoding'. If - * that cannot be found then default to "latin1". - * Note: VIM specific encoding header is always skipped. - */ + // Find an encoding to use for printing. + // Check 'printencoding'. If not set or not found, then use 'encoding'. If + // that cannot be found then default to "latin1". + // Note: VIM specific encoding header is always skipped. if (!prt_out_mbyte) { p_encoding = enc_skip(p_penc); if (*p_encoding == NUL || !prt_find_resource((char *)p_encoding, res_encoding)) { - /* 'printencoding' not set or not supported - find alternate */ + // 'printencoding' not set or not supported - find alternate int props; p_encoding = enc_skip(p_enc); props = enc_canon_props(p_encoding); if (!(props & ENC_8BIT) || !prt_find_resource((char *)p_encoding, res_encoding)) - /* 8-bit 'encoding' is not supported */ - { - /* Use latin1 as default printing encoding */ + // 8-bit 'encoding' is not supported + { + // Use latin1 as default printing encoding p_encoding = (char_u *)"latin1"; if (!prt_find_resource((char *)p_encoding, res_encoding)) { @@ -2868,8 +2859,8 @@ mch_print_begin(prt_settings_T *psetting } if (!prt_open_resource(res_encoding)) goto theend; - /* For the moment there are no checks on encoding resource files to - * perform */ + // For the moment there are no checks on encoding resource files to + // perform } else { @@ -2878,7 +2869,7 @@ mch_print_begin(prt_settings_T *psetting p_encoding = enc_skip(p_enc); if (prt_use_courier) { - /* Include ASCII range encoding vector */ + // Include ASCII range encoding vector if (!prt_find_resource(prt_ascii_encoding, res_encoding)) { semsg(_("E456: Can't find PostScript resource file \"%s.ps\""), @@ -2887,14 +2878,14 @@ mch_print_begin(prt_settings_T *psetting } if (!prt_open_resource(res_encoding)) goto theend; - /* For the moment there are no checks on encoding resource files to - * perform */ + // For the moment there are no checks on encoding resource files to + // perform } } prt_conv.vc_type = CONV_NONE; if (!(enc_canon_props(p_enc) & enc_canon_props(p_encoding) & ENC_8BIT)) { - /* Set up encoding conversion if required */ + // Set up encoding conversion if required if (FAIL == convert_setup(&prt_conv, p_enc, p_encoding)) { semsg(_("E620: Unable to convert to print encoding \"%s\""), @@ -2907,7 +2898,7 @@ mch_print_begin(prt_settings_T *psetting if (prt_out_mbyte && prt_custom_cmap) { - /* Find user supplied CMap */ + // Find user supplied CMap if (!prt_find_resource(prt_cmap, res_cmap)) { semsg(_("E456: Can't find PostScript resource file \"%s.ps\""), @@ -2918,7 +2909,7 @@ mch_print_begin(prt_settings_T *psetting goto theend; } - /* List resources supplied */ + // List resources supplied STRCPY(buffer, res_prolog->title); STRCAT(buffer, " "); STRCAT(buffer, res_prolog->version); @@ -2959,7 +2950,7 @@ mch_print_begin(prt_settings_T *psetting */ prt_dsc_noarg("BeginDefaults"); - /* List font resources most likely common to all pages */ + // List font resources most likely common to all pages if (!prt_out_mbyte || prt_use_courier) prt_dsc_font_resource("PageResources", &prt_ps_courier_font); if (prt_out_mbyte) @@ -2970,7 +2961,7 @@ mch_print_begin(prt_settings_T *psetting prt_dsc_resources(NULL, "cmap", prt_cmap); } - /* Paper will be used for all pages */ + // Paper will be used for all pages prt_dsc_textline("PageMedia", prt_mediasize[prt_media].name); prt_dsc_noarg("EndDefaults"); @@ -2980,12 +2971,12 @@ mch_print_begin(prt_settings_T *psetting */ prt_dsc_noarg("BeginProlog"); - /* Add required procsets - NOTE: order is important! */ + // Add required procsets - NOTE: order is important! if (!prt_add_resource(res_prolog)) goto theend; if (prt_out_mbyte) { - /* Add CID font procset, and any user supplied CMap */ + // Add CID font procset, and any user supplied CMap if (!prt_add_resource(res_cidfont)) goto theend; if (prt_custom_cmap && !prt_add_resource(res_cmap)) @@ -2993,8 +2984,8 @@ mch_print_begin(prt_settings_T *psetting } if (!prt_out_mbyte || prt_use_courier) - /* There will be only one Roman font encoding to be included in the PS - * file. */ + // There will be only one Roman font encoding to be included in the PS + // file. if (!prt_add_resource(res_encoding)) goto theend; @@ -3005,7 +2996,7 @@ mch_print_begin(prt_settings_T *psetting */ prt_dsc_noarg("BeginSetup"); - /* Device setup - page size and number of uncollated copies */ + // Device setup - page size and number of uncollated copies prt_write_int((int)prt_mediasize[prt_media].width); prt_write_int((int)prt_mediasize[prt_media].height); prt_write_int(0); @@ -3018,11 +3009,11 @@ mch_print_begin(prt_settings_T *psetting prt_write_boolean(prt_collate); prt_write_string("c\n"); - /* Font resource inclusion and definition */ + // Font resource inclusion and definition if (!prt_out_mbyte || prt_use_courier) { - /* When using Courier for ASCII range when printing multi-byte, need to - * pick up ASCII encoding to use with it. */ + // When using Courier for ASCII range when printing multi-byte, need to + // pick up ASCII encoding to use with it. if (prt_use_courier) p_encoding = (char_u *)prt_ascii_encoding; prt_dsc_resources("IncludeResource", "font", @@ -3044,12 +3035,11 @@ mch_print_begin(prt_settings_T *psetting } if (prt_out_mbyte) { - /* Define the CID fonts to be used in the job. Typically CJKV fonts do - * not have an italic form being a western style, so where no font is - * defined for these faces VIM falls back to an existing face. - * Note: if using Courier for the ASCII range then the printout will - * have bold/italic/bolditalic regardless of the setting of printmbfont. - */ + // Define the CID fonts to be used in the job. Typically CJKV fonts do + // not have an italic form being a western style, so where no font is + // defined for these faces VIM falls back to an existing face. + // Note: if using Courier for the ASCII range then the printout will + // have bold/italic/bolditalic regardless of the setting of printmbfont. prt_dsc_resources("IncludeResource", "font", prt_ps_mb_font.ps_fontname[PRT_PS_FONT_ROMAN]); if (!prt_custom_cmap) @@ -3067,7 +3057,7 @@ mch_print_begin(prt_settings_T *psetting prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLD]); } else - /* Use ROMAN for BOLD */ + // Use ROMAN for BOLD prt_dup_cidfont("CF0", "CF1"); if (prt_ps_mb_font.ps_fontname[PRT_PS_FONT_OBLIQUE] != NULL) @@ -3080,7 +3070,7 @@ mch_print_begin(prt_settings_T *psetting prt_ps_mb_font.ps_fontname[PRT_PS_FONT_OBLIQUE]); } else - /* Use ROMAN for OBLIQUE */ + // Use ROMAN for OBLIQUE prt_dup_cidfont("CF0", "CF2"); if (prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE] != NULL) @@ -3093,11 +3083,11 @@ mch_print_begin(prt_settings_T *psetting prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]); } else - /* Use BOLD for BOLDOBLIQUE */ + // Use BOLD for BOLDOBLIQUE prt_dup_cidfont("CF1", "CF3"); } - /* Misc constant vars used for underlining and background rects */ + // Misc constant vars used for underlining and background rects prt_def_var("UO", PRT_PS_FONT_TO_USER(prt_line_height, prt_ps_font->uline_offset), 2); prt_def_var("UW", PRT_PS_FONT_TO_USER(prt_line_height, @@ -3106,7 +3096,7 @@ mch_print_begin(prt_settings_T *psetting prt_dsc_noarg("EndSetup"); - /* Fail if any problems writing out to the PS file */ + // Fail if any problems writing out to the PS file retval = !prt_file_error; theend: @@ -3130,14 +3120,14 @@ mch_print_end(prt_settings_T *psettings) prt_dsc_noarg("EOF"); - /* Write CTRL-D to close serial communication link if used. - * NOTHING MUST BE WRITTEN AFTER THIS! */ + // Write CTRL-D to close serial communication link if used. + // NOTHING MUST BE WRITTEN AFTER THIS! prt_write_file((char_u *)IF_EB("\004", "\067")); if (!prt_file_error && psettings->outfile == NULL && !got_int && !psettings->user_abort) { - /* Close the file first. */ + // Close the file first. if (prt_ps_fd != NULL) { fclose(prt_ps_fd); @@ -3145,7 +3135,7 @@ mch_print_end(prt_settings_T *psettings) } prt_message((char_u *)_("Sending to printer...")); - /* Not printing to a file: use 'printexpr' to print the file. */ + // Not printing to a file: use 'printexpr' to print the file. if (eval_printexpr(prt_ps_file_name, psettings->arguments) == FAIL) emsg(_("E365: Failed to print PostScript file")); else @@ -3189,7 +3179,7 @@ mch_print_begin_page(char_u *str UNUSED) prt_bgcol = PRCOLOR_WHITE; prt_font = PRT_PS_FONT_ROMAN; - /* Set up page transformation for landscape printing. */ + // Set up page transformation for landscape printing. if (!prt_portrait) { prt_write_int(-((int)prt_mediasize[prt_media].width)); @@ -3198,7 +3188,7 @@ mch_print_begin_page(char_u *str UNUSED) prt_dsc_noarg("EndPageSetup"); - /* We have reset the font attributes, force setting them again. */ + // We have reset the font attributes, force setting them again. curr_bg = (long_u)0xffffffff; curr_fg = (long_u)0xffffffff; curr_bold = MAYBE; @@ -3245,13 +3235,12 @@ mch_print_text_out(char_u *textp, int le char_width = prt_char_width; - /* Ideally VIM would create a rearranged CID font to combine a Roman and - * CJKV font to do what VIM is doing here - use a Roman font for characters - * in the ASCII range, and the original CID font for everything else. - * The problem is that GhostScript still (as of 8.13) does not support - * rearranged fonts even though they have been documented by Adobe for 7 - * years! If they ever do, a lot of this code will disappear. - */ + // Ideally VIM would create a rearranged CID font to combine a Roman and + // CJKV font to do what VIM is doing here - use a Roman font for characters + // in the ASCII range, and the original CID font for everything else. + // The problem is that GhostScript still (as of 8.13) does not support + // rearranged fonts even though they have been documented by Adobe for 7 + // years! If they ever do, a lot of this code will disappear. if (prt_use_courier) { in_ascii = (len == 1 && *p < 0x80); @@ -3259,7 +3248,7 @@ mch_print_text_out(char_u *textp, int le { if (!in_ascii) { - /* No longer in ASCII range - need to switch font */ + // No longer in ASCII range - need to switch font prt_in_ascii = FALSE; prt_need_font = TRUE; prt_attribute_change = TRUE; @@ -3267,7 +3256,7 @@ mch_print_text_out(char_u *textp, int le } else if (in_ascii) { - /* Now in ASCII range - need to switch font */ + // Now in ASCII range - need to switch font prt_in_ascii = TRUE; prt_need_font = TRUE; prt_attribute_change = TRUE; @@ -3297,13 +3286,12 @@ mch_print_text_out(char_u *textp, int le } } - /* Output any required changes to the graphics state, after flushing any - * text buffered so far. - */ + // Output any required changes to the graphics state, after flushing any + // text buffered so far. if (prt_attribute_change) { prt_flush_buffer(); - /* Reset count of number of chars that will be printed */ + // Reset count of number of chars that will be printed prt_text_run = 0; if (prt_need_moveto) @@ -3362,7 +3350,7 @@ mch_print_text_out(char_u *textp, int le if (prt_do_conv) { - /* Convert from multi-byte to 8-bit encoding */ + // Convert from multi-byte to 8-bit encoding tofree = p = string_convert(&prt_conv, p, &len); if (p == NULL) { @@ -3373,9 +3361,8 @@ mch_print_text_out(char_u *textp, int le if (prt_out_mbyte) { - /* Multi-byte character strings are represented more efficiently as hex - * strings when outputting clean 8 bit PS. - */ + // Multi-byte character strings are represented more efficiently as hex + // strings when outputting clean 8 bit PS. while (len-- > 0) { ch = prt_hexchar[(unsigned)(*p) >> 4]; @@ -3387,19 +3374,17 @@ mch_print_text_out(char_u *textp, int le } else { - /* Add next character to buffer of characters to output. - * Note: One printed character may require several PS characters to - * represent it, but we only count them as one printed character. - */ + // Add next character to buffer of characters to output. + // Note: One printed character may require several PS characters to + // represent it, but we only count them as one printed character. ch = *p; if (ch < 32 || ch == '(' || ch == ')' || ch == '\\') { - /* Convert non-printing characters to either their escape or octal - * sequence, ensures PS sent over a serial line does not interfere - * with the comms protocol. Note: For EBCDIC we need to write out - * the escape sequences as ASCII codes! - * Note 2: Char codes < 32 are identical in EBCDIC and ASCII AFAIK! - */ + // Convert non-printing characters to either their escape or octal + // sequence, ensures PS sent over a serial line does not interfere + // with the comms protocol. Note: For EBCDIC we need to write out + // the escape sequences as ASCII codes! + // Note 2: Char codes < 32 are identical in EBCDIC and ASCII AFAIK! ga_append(&prt_ps_buffer, IF_EB('\\', 0134)); switch (ch) { @@ -3427,13 +3412,13 @@ mch_print_text_out(char_u *textp, int le ga_append(&prt_ps_buffer, ch); } - /* Need to free any translated characters */ + // Need to free any translated characters vim_free(tofree); prt_text_run += char_width; prt_pos_x += char_width; - /* The downside of fp - use relative error on right margin check */ + // The downside of fp - use relative error on right margin check next_pos = prt_pos_x + prt_char_width; need_break = (next_pos > prt_right_margin) && ((next_pos - prt_right_margin) > (prt_right_margin*1e-5)); @@ -3487,5 +3472,5 @@ mch_print_set_fg(long_u fgcol) } } -# endif /*FEAT_POSTSCRIPT*/ -#endif /*FEAT_PRINTER*/ +# endif //FEAT_POSTSCRIPT +#endif //FEAT_PRINTER
--- a/src/hashtab.c +++ b/src/hashtab.c @@ -30,18 +30,18 @@ #include "vim.h" #if 0 -# define HT_DEBUG /* extra checks for table consistency and statistics */ +# define HT_DEBUG // extra checks for table consistency and statistics -static long hash_count_lookup = 0; /* count number of hashtab lookups */ -static long hash_count_perturb = 0; /* count number of "misses" */ +static long hash_count_lookup = 0; // count number of hashtab lookups +static long hash_count_perturb = 0; // count number of "misses" #endif -/* Magic value for algorithm that walks through the array. */ +// Magic value for algorithm that walks through the array. #define PERTURB_SHIFT 5 static int hash_may_resize(hashtab_T *ht, int minitems); -#if 0 /* currently not used */ +#if 0 // currently not used /* * Create an empty hash table. * Returns NULL when out of memory. @@ -64,7 +64,7 @@ hash_create(void) void hash_init(hashtab_T *ht) { - /* This zeroes all "ht_" entries and all the "hi_key" in "ht_smallarray". */ + // This zeroes all "ht_" entries and all the "hi_key" in "ht_smallarray". vim_memset(ht, 0, sizeof(hashtab_T)); ht->ht_array = ht->ht_smallarray; ht->ht_mask = HT_INIT_SIZE - 1; @@ -165,7 +165,7 @@ hash_lookup(hashtab_T *ht, char_u *key, for (perturb = hash; ; perturb >>= PERTURB_SHIFT) { #ifdef HT_DEBUG - ++hash_count_perturb; /* count a "miss" for hashtab lookup */ + ++hash_count_perturb; // count a "miss" for hashtab lookup #endif idx = (unsigned)((idx << 2U) + idx + perturb + 1U); hi = &ht->ht_array[idx & ht->ht_mask]; @@ -231,7 +231,7 @@ hash_add_item( char_u *key, hash_T hash) { - /* If resizing failed before and it fails again we can't add an item. */ + // If resizing failed before and it fails again we can't add an item. if (ht->ht_error && hash_may_resize(ht, 0) == FAIL) return FAIL; @@ -241,11 +241,11 @@ hash_add_item( hi->hi_key = key; hi->hi_hash = hash; - /* When the space gets low may resize the array. */ + // When the space gets low may resize the array. return hash_may_resize(ht, 0); } -#if 0 /* not used */ +#if 0 // not used /* * Overwrite hashtable item "hi" with "key". "hi" must point to the item that * is to be overwritten. Thus the number of items in the hashtable doesn't @@ -318,7 +318,7 @@ hash_unlock(hashtab_T *ht) static int hash_may_resize( hashtab_T *ht, - int minitems) /* minimal number of items */ + int minitems) // minimal number of items { hashitem_T temparray[HT_INIT_SIZE]; hashitem_T *oldarray, *newarray; @@ -330,7 +330,7 @@ hash_may_resize( long_u newmask; hash_T perturb; - /* Don't resize a locked table. */ + // Don't resize a locked table. if (ht->ht_locked > 0) return OK; @@ -343,8 +343,8 @@ hash_may_resize( if (minitems == 0) { - /* Return quickly for small tables with at least two NULL items. NULL - * items are required for the lookup to decide a key isn't there. */ + // Return quickly for small tables with at least two NULL items. NULL + // items are required for the lookup to decide a key isn't there. if (ht->ht_filled < HT_INIT_SIZE - 1 && ht->ht_array == ht->ht_smallarray) return OK; @@ -360,9 +360,9 @@ hash_may_resize( return OK; if (ht->ht_used > 1000) - minsize = ht->ht_used * 2; /* it's big, don't make too much room */ + minsize = ht->ht_used * 2; // it's big, don't make too much room else - minsize = ht->ht_used * 4; /* make plenty of room */ + minsize = ht->ht_used * 4; // make plenty of room } else { @@ -375,20 +375,20 @@ hash_may_resize( newsize = HT_INIT_SIZE; while (newsize < minsize) { - newsize <<= 1; /* make sure it's always a power of 2 */ + newsize <<= 1; // make sure it's always a power of 2 if (newsize == 0) - return FAIL; /* overflow */ + return FAIL; // overflow } if (newsize == HT_INIT_SIZE) { - /* Use the small array inside the hashdict structure. */ + // Use the small array inside the hashdict structure. newarray = ht->ht_smallarray; if (ht->ht_array == newarray) { - /* Moving from ht_smallarray to ht_smallarray! Happens when there - * are many removed items. Copy the items to be able to clean up - * removed items. */ + // Moving from ht_smallarray to ht_smallarray! Happens when there + // are many removed items. Copy the items to be able to clean up + // removed items. mch_memmove(temparray, newarray, sizeof(temparray)); oldarray = temparray; } @@ -397,13 +397,13 @@ hash_may_resize( } else { - /* Allocate an array. */ + // Allocate an array. newarray = ALLOC_MULT(hashitem_T, newsize); if (newarray == NULL) { - /* Out of memory. When there are NULL items still return OK. - * Otherwise set ht_error, because lookup may result in a hang if - * we add another item. */ + // Out of memory. When there are NULL items still return OK. + // Otherwise set ht_error, because lookup may result in a hang if + // we add another item. if (ht->ht_filled < ht->ht_mask) return OK; ht->ht_error = TRUE; @@ -470,8 +470,8 @@ hash_hash(char_u *key) return (hash_T)0; p = key + 1; - /* A simplistic algorithm that appears to do very well. - * Suggested by George Reilly. */ + // A simplistic algorithm that appears to do very well. + // Suggested by George Reilly. while (*p != NUL) hash = hash * 101 + *p++;
--- a/src/if_cscope.c +++ b/src/if_cscope.c @@ -51,11 +51,11 @@ static int cs_show(exarg_T *eap); static csinfo_T * csinfo = NULL; -static int csinfo_size = 0; /* number of items allocated in - csinfo[] */ +static int csinfo_size = 0; // number of items allocated in + // csinfo[] -static int eap_arg_len; /* length of eap->arg, set in - cs_lookup_cmd() */ +static int eap_arg_len; // length of eap->arg, set in + // cs_lookup_cmd() static cscmd_T cs_cmds[] = { { "add", cs_add, @@ -81,10 +81,10 @@ cs_usage_msg(csid_e x) static enum { - EXP_CSCOPE_SUBCMD, /* expand ":cscope" sub-commands */ - EXP_SCSCOPE_SUBCMD, /* expand ":scscope" sub-commands */ - EXP_CSCOPE_FIND, /* expand ":cscope find" arguments */ - EXP_CSCOPE_KILL /* expand ":cscope kill" arguments */ + EXP_CSCOPE_SUBCMD, // expand ":cscope" sub-commands + EXP_SCSCOPE_SUBCMD, // expand ":scscope" sub-commands + EXP_CSCOPE_FIND, // expand ":cscope find" arguments + EXP_CSCOPE_KILL // expand ":cscope kill" arguments } expand_what; /* @@ -100,12 +100,12 @@ get_cscope_name(expand_T *xp UNUSED, int switch (expand_what) { case EXP_CSCOPE_SUBCMD: - /* Complete with sub-commands of ":cscope": - * add, find, help, kill, reset, show */ + // Complete with sub-commands of ":cscope": + // add, find, help, kill, reset, show return (char_u *)cs_cmds[idx].name; case EXP_SCSCOPE_SUBCMD: - /* Complete with sub-commands of ":scscope": same sub-commands as - * ":cscope" but skip commands which don't support split windows */ + // Complete with sub-commands of ":scscope": same sub-commands as + // ":cscope" but skip commands which don't support split windows for (i = 0, current_idx = 0; cs_cmds[i].name != NULL; i++) if (cs_cmds[i].cansplit) if (current_idx++ == idx) @@ -118,20 +118,20 @@ get_cscope_name(expand_T *xp UNUSED, int "a", "c", "d", "e", "f", "g", "i", "s", "t", NULL }; - /* Complete with query type of ":cscope find {query_type}". - * {query_type} can be letters (c, d, ... a) or numbers (0, 1, - * ..., 9) but only complete with letters, since numbers are - * redundant. */ + // Complete with query type of ":cscope find {query_type}". + // {query_type} can be letters (c, d, ... a) or numbers (0, 1, + // ..., 9) but only complete with letters, since numbers are + // redundant. return (char_u *)query_type[idx]; } case EXP_CSCOPE_KILL: { static char connection[5]; - /* ":cscope kill" accepts connection numbers or partial names of - * the pathname of the cscope database as argument. Only complete - * with connection numbers. -1 can also be used to kill all - * connections. */ + // ":cscope kill" accepts connection numbers or partial names of + // the pathname of the cscope database as argument. Only complete + // with connection numbers. -1 can also be used to kill all + // connections. for (i = 0, current_idx = 0; i < csinfo_size; i++) { if (csinfo[i].fname == NULL) @@ -160,17 +160,17 @@ set_context_in_cscope_cmd( { char_u *p; - /* Default: expand subcommands */ + // Default: expand subcommands xp->xp_context = EXPAND_CSCOPE; xp->xp_pattern = arg; expand_what = (cmdidx == CMD_scscope) ? EXP_SCSCOPE_SUBCMD : EXP_CSCOPE_SUBCMD; - /* (part of) subcommand already typed */ + // (part of) subcommand already typed if (*arg != NUL) { p = skiptowhite(arg); - if (*p != NUL) /* past first word */ + if (*p != NUL) // past first word { xp->xp_pattern = skipwhite(p); if (*skiptowhite(xp->xp_pattern) != NUL) @@ -194,7 +194,7 @@ set_context_in_cscope_cmd( static void do_cscope_general( exarg_T *eap, - int make_split UNUSED) /* whether to split window */ + int make_split UNUSED) // whether to split window { cscmd_T *cmdp; @@ -333,7 +333,7 @@ cs_fgets(char_u *buf, int size) vim_strncpy(buf, (char_u *)p, size - 1); return FALSE; -} /* cs_fgets */ +} /* @@ -483,8 +483,8 @@ cs_stat_emsg(char *fname) */ static int cs_add_common( - char *arg1, /* filename - may contain environment variables */ - char *arg2, /* prepend path - may contain environment variables */ + char *arg1, // filename - may contain environment variables + char *arg2, // prepend path - may contain environment variables char *flags) { stat_T statbuf; @@ -497,7 +497,7 @@ cs_add_common( int usedlen = 0; char_u *fbuf = NULL; - /* get the filename (arg1), expand it, and try to stat it */ + // get the filename (arg1), expand it, and try to stat it if ((fname = alloc(MAXPATHL + 1)) == NULL) goto add_err; @@ -520,7 +520,7 @@ staterr: goto add_err; } - /* get the prepend path (arg2), expand it, and try to stat it */ + // get the prepend path (arg2), expand it, and try to stat it if (arg2 != NULL) { stat_T statbuf2; @@ -534,7 +534,7 @@ staterr: goto staterr; } - /* if filename is a directory, append the cscope database name to it */ + // if filename is a directory, append the cscope database name to it if (S_ISDIR(statbuf.st_mode)) { fname2 = alloc(strlen(CSCOPE_DBFILE) + strlen(fname) + 2); @@ -607,21 +607,21 @@ add_err: vim_free(fname); vim_free(ppath); return CSCOPE_FAILURE; -} /* cs_add_common */ +} static int cs_check_for_connections(void) { return (cs_cnt_connections() > 0); -} /* cs_check_for_connections */ +} static int cs_check_for_tags(void) { return (p_tags[0] != NUL && curbuf->b_p_tags != NULL); -} /* cs_check_for_tags */ +} /* @@ -639,11 +639,11 @@ cs_cnt_connections(void) cnt++; } return cnt; -} /* cs_cnt_connections */ +} static void cs_reading_emsg( - int idx) /* connection index */ + int idx) // connection index { semsg(_("E262: error reading cscope connection %d"), idx); } @@ -708,7 +708,7 @@ cs_cnt_matches(int idx) vim_free(buf); return nlines; -} /* cs_cnt_matches */ +} /* @@ -756,8 +756,8 @@ cs_create_cmd(char *csoption, char *patt return NULL; } - /* Skip white space before the patter, except for text and pattern search, - * they may want to use the leading white space. */ + // Skip white space before the patter, except for text and pattern search, + // they may want to use the leading white space. pat = pattern; if (search != 4 && search != 6) while VIM_ISWHITE(*pat) @@ -769,7 +769,7 @@ cs_create_cmd(char *csoption, char *patt (void)sprintf(cmd, "%d%s", search, pat); return cmd; -} /* cs_create_cmd */ +} /* @@ -826,7 +826,7 @@ err_closing: case -1: (void)emsg(_("E622: Could not fork for cscope")); goto err_closing; - case 0: /* child: run cscope. */ + case 0: // child: run cscope. if (dup2(to_cs[0], STDIN_FILENO) == -1) PERROR("cs_create_connection 1"); if (dup2(from_cs[1], STDOUT_FILENO) == -1) @@ -834,12 +834,12 @@ err_closing: if (dup2(from_cs[1], STDERR_FILENO) == -1) PERROR("cs_create_connection 3"); - /* close unused */ + // close unused (void)close(to_cs[1]); (void)close(from_cs[0]); #else - /* MSWIN */ - /* Create pipes to communicate with cscope */ + // MSWIN + // Create pipes to communicate with cscope sa.nLength = sizeof(SECURITY_ATTRIBUTES); sa.bInheritHandle = TRUE; sa.lpSecurityDescriptor = NULL; @@ -862,30 +862,30 @@ err_closing: return CSCOPE_FAILURE; } #endif - /* expand the cscope exec for env var's */ + // expand the cscope exec for env var's if ((prog = alloc(MAXPATHL + 1)) == NULL) { #ifdef UNIX return CSCOPE_FAILURE; #else - /* MSWIN */ + // MSWIN goto err_closing; #endif } expand_env((char_u *)p_csprg, (char_u *)prog, MAXPATHL); - /* alloc space to hold the cscope command */ + // alloc space to hold the cscope command len = (int)(strlen(prog) + strlen(csinfo[i].fname) + 32); if (csinfo[i].ppath) { - /* expand the prepend path for env var's */ + // expand the prepend path for env var's if ((ppath = alloc(MAXPATHL + 1)) == NULL) { vim_free(prog); #ifdef UNIX return CSCOPE_FAILURE; #else - /* MSWIN */ + // MSWIN goto err_closing; #endif } @@ -904,16 +904,16 @@ err_closing: #ifdef UNIX return CSCOPE_FAILURE; #else - /* MSWIN */ + // MSWIN goto err_closing; #endif } - /* run the cscope command; is there execl for non-unix systems? */ + // run the cscope command; is there execl for non-unix systems? #if defined(UNIX) (void)sprintf(cmd, "exec %s -dl -f %s", prog, csinfo[i].fname); #else - /* MSWIN */ + // MSWIN (void)sprintf(cmd, "%s -dl -f %s", prog, csinfo[i].fname); #endif if (csinfo[i].ppath != NULL) @@ -927,14 +927,14 @@ err_closing: (void)strcat(cmd, csinfo[i].flags); } # ifdef UNIX - /* on Win32 we still need prog */ + // on Win32 we still need prog vim_free(prog); # endif vim_free(ppath); #if defined(UNIX) # if defined(HAVE_SETSID) || defined(HAVE_SETPGID) - /* Change our process group to avoid cscope receiving SIGWINCH. */ + // Change our process group to avoid cscope receiving SIGWINCH. # if defined(HAVE_SETSID) (void)setsid(); # else @@ -946,8 +946,8 @@ err_closing: PERROR(_("cs_create_connection exec failed")); exit(127); - /* NOTREACHED */ - default: /* parent. */ + // NOTREACHED + default: // parent. /* * Save the file descriptors for later duplication, and * reopen as streams. @@ -957,7 +957,7 @@ err_closing: if ((csinfo[i].fr_fp = fdopen(from_cs[0], "r")) == NULL) PERROR(_("cs_create_connection: fdopen for fr_fp failed")); - /* close unused */ + // close unused (void)close(to_cs[0]); (void)close(from_cs[1]); @@ -965,11 +965,11 @@ err_closing: } #else - /* MSWIN */ - /* Create a new process to run cscope and use pipes to talk with it */ + // MSWIN + // Create a new process to run cscope and use pipes to talk with it GetStartupInfo(&si); si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; - si.wShowWindow = SW_HIDE; /* Hide child application window */ + si.wShowWindow = SW_HIDE; // Hide child application window si.hStdOutput = stdout_wr; si.hStdError = stdout_wr; si.hStdInput = stdin_rd; @@ -984,12 +984,12 @@ err_closing: (void)emsg(_("E623: Could not spawn cscope process")); goto err_closing; } - /* else */ + // else csinfo[i].pid = pi.dwProcessId; csinfo[i].hProc = pi.hProcess; CloseHandle(pi.hThread); - /* TODO - tidy up after failure to create files on pipe handles. */ + // TODO - tidy up after failure to create files on pipe handles. if (((fd = _open_osfhandle((OPEN_OH_ARGTYPE)stdin_wr, _O_TEXT|_O_APPEND)) < 0) || ((csinfo[i].to_fp = _fdopen(fd, "w")) == NULL)) @@ -999,14 +999,14 @@ err_closing: || ((csinfo[i].fr_fp = _fdopen(fd, "r")) == NULL)) PERROR(_("cs_create_connection: fdopen for fr_fp failed")); - /* Close handles for file descriptors inherited by the cscope process */ + // Close handles for file descriptors inherited by the cscope process CloseHandle(stdin_rd); CloseHandle(stdout_wr); -#endif /* !UNIX */ +#endif // !UNIX return CSCOPE_SUCCESS; -} /* cs_create_connection */ +} /* @@ -1050,7 +1050,7 @@ cs_find(exarg_T *eap) return cs_find_common(opt, pat, eap->forceit, TRUE, eap->cmdidx == CMD_lcscope, *eap->cmdlinep); -} /* cs_find */ +} /* @@ -1073,7 +1073,7 @@ cs_find_common( char cmdletter; char *qfpos; - /* get cmd letter */ + // get cmd letter switch (opt[0]) { case '0' : @@ -1111,13 +1111,13 @@ cs_find_common( if (qfpos != NULL) { qfpos++; - /* next symbol must be + or - */ + // next symbol must be + or - if (strchr(CSQF_FLAGS, *qfpos) == NULL) { char *nf = _("E469: invalid cscopequickfix flag %c for %c"); char *buf = alloc(strlen(nf)); - /* strlen will be enough because we use chars */ + // strlen will be enough because we use chars if (buf != NULL) { sprintf(buf, nf, *qfpos, *(qfpos-1)); @@ -1139,7 +1139,7 @@ cs_find_common( } #endif - /* create the actual command to send to cscope */ + // create the actual command to send to cscope cmd = cs_create_cmd(opt, pat); if (cmd == NULL) return FALSE; @@ -1151,8 +1151,8 @@ cs_find_common( return FALSE; } - /* Send query to all open connections, then count the total number - * of matches so we can alloc all in one swell foop. */ + // Send query to all open connections, then count the total number + // of matches so we can alloc all in one swell foop. for (i = 0; i < csinfo_size; i++) nummatches[i] = 0; totmatches = 0; @@ -1161,7 +1161,7 @@ cs_find_common( if (csinfo[i].fname == NULL || csinfo[i].to_fp == NULL) continue; - /* send cmd to cscope */ + // send cmd to cscope (void)fprintf(csinfo[i].to_fp, "%s\n", cmd); (void)fflush(csinfo[i].to_fp); @@ -1202,7 +1202,7 @@ cs_find_common( #ifdef FEAT_QUICKFIX if (qfpos != NULL && *qfpos != '0' && totmatches > 0) { - /* fill error list */ + // fill error list FILE *f; char_u *tmp = vim_tempname('c', TRUE); qf_info_T *qi = NULL; @@ -1215,9 +1215,9 @@ cs_find_common( { cs_file_results(f, nummatches); fclose(f); - if (use_ll) /* Use location list */ + if (use_ll) // Use location list wp = curwin; - /* '-' starts a new error list */ + // '-' starts a new error list if (qf_init(wp, tmp, (char_u *)"%f%*\\t%l%*\\t%m", *qfpos == '-', cmdline, NULL) > 0) { @@ -1247,12 +1247,12 @@ cs_find_common( return TRUE; } else -#endif /* FEAT_QUICKFIX */ +#endif // FEAT_QUICKFIX { char **matches = NULL, **contexts = NULL; int matched = 0; - /* read output */ + // read output cs_fill_results((char *)pat, totmatches, nummatches, &matches, &contexts, &matched); vim_free(nummatches); @@ -1264,7 +1264,7 @@ cs_find_common( return do_tag((char_u *)pat, DT_CSCOPE, 0, forceit, verbose); } -} /* cs_find_common */ +} /* * Print help. @@ -1280,7 +1280,7 @@ cs_help(exarg_T *eap UNUSED) char *help = _(cmdp->help); int space_cnt = 30 - vim_strsize((char_u *)help); - /* Use %*s rather than %30s to ensure proper alignment in utf-8 */ + // Use %*s rather than %30s to ensure proper alignment in utf-8 if (space_cnt < 0) space_cnt = 0; (void)smsg(_("%-5s: %s%*s (Usage: %s)"), @@ -1304,7 +1304,7 @@ cs_help(exarg_T *eap UNUSED) wait_return(TRUE); return 0; -} /* cs_help */ +} static void @@ -1338,7 +1338,7 @@ GetWin32Error(void) NULL, GetLastError(), 0, (LPSTR)&msg, 0, NULL); if (msg != NULL) { - /* remove trailing \r\n */ + // remove trailing \r\n char *pcrlf = strstr(msg, "\r\n"); if (pcrlf != NULL) *pcrlf = '\0'; @@ -1363,8 +1363,8 @@ cs_insert_filelist( switch (win32_fileinfo((char_u *)fname, &bhfi)) { - case FILEINFO_ENC_FAIL: /* enc_to_utf16() failed */ - case FILEINFO_READ_FAIL: /* CreateFile() failed */ + case FILEINFO_ENC_FAIL: // enc_to_utf16() failed + case FILEINFO_READ_FAIL: // CreateFile() failed if (p_csverbose) { char *cant_msg = _("E625: cannot open cscope database: %s"); @@ -1376,19 +1376,19 @@ cs_insert_filelist( LocalFree(winmsg); } else - /* subst filename if can't get error text */ + // subst filename if can't get error text (void)semsg(cant_msg, fname); } return -1; - case FILEINFO_INFO_FAIL: /* GetFileInformationByHandle() failed */ + case FILEINFO_INFO_FAIL: // GetFileInformationByHandle() failed if (p_csverbose) (void)emsg(_("E626: cannot get cscope database information")); return -1; } #endif - i = -1; /* can be set to the index of an empty item in csinfo */ + i = -1; // can be set to the index of an empty item in csinfo for (j = 0; j < csinfo_size; j++) { if (csinfo[j].fname != NULL @@ -1411,7 +1411,7 @@ cs_insert_filelist( } if (csinfo[j].fname == NULL && i == -1) - i = j; /* remember first empty entry */ + i = j; // remember first empty entry } if (i == -1) @@ -1419,9 +1419,9 @@ cs_insert_filelist( i = csinfo_size; if (csinfo_size == 0) { - /* First time allocation: allocate only 1 connection. It should - * be enough for most users. If more is needed, csinfo will be - * reallocated. */ + // First time allocation: allocate only 1 connection. It should + // be enough for most users. If more is needed, csinfo will be + // reallocated. csinfo_size = 1; csinfo = ALLOC_CLEAR_ONE(csinfo_T); } @@ -1429,7 +1429,7 @@ cs_insert_filelist( { csinfo_T *t_csinfo = csinfo; - /* Reallocate space for more connections. */ + // Reallocate space for more connections. csinfo_size *= 2; csinfo = vim_realloc(csinfo, sizeof(csinfo_T)*csinfo_size); if (csinfo == NULL) @@ -1482,7 +1482,7 @@ cs_insert_filelist( csinfo[i].nIndexHigh = bhfi.nFileIndexHigh; #endif return i; -} /* cs_insert_filelist */ +} /* @@ -1498,7 +1498,7 @@ cs_lookup_cmd(exarg_T *eap) if (eap->arg == NULL) return NULL; - /* Store length of eap->arg before it gets modified by strtok(). */ + // Store length of eap->arg before it gets modified by strtok(). eap_arg_len = (int)STRLEN(eap->arg); if ((stok = strtok((char *)(eap->arg), (const char *)" ")) == NULL) @@ -1511,7 +1511,7 @@ cs_lookup_cmd(exarg_T *eap) return (cmdp); } return NULL; -} /* cs_lookup_cmd */ +} /* @@ -1529,16 +1529,15 @@ cs_kill(exarg_T *eap UNUSED) return CSCOPE_FAILURE; } - /* only single digit positive and negative integers are allowed */ + // only single digit positive and negative integers are allowed if ((strlen(stok) < 2 && VIM_ISDIGIT((int)(stok[0]))) || (strlen(stok) < 3 && stok[0] == '-' && VIM_ISDIGIT((int)(stok[1])))) i = atoi(stok); else { - /* It must be part of a name. We will try to find a match - * within all the names in the csinfo data structure - */ + // It must be part of a name. We will try to find a match + // within all the names in the csinfo data structure for (i = 0; i < csinfo_size; i++) { if (csinfo[i].fname != NULL && strstr(csinfo[i].fname, stok)) @@ -1566,7 +1565,7 @@ cs_kill(exarg_T *eap UNUSED) } return 0; -} /* cs_kill */ +} /* @@ -1574,8 +1573,8 @@ cs_kill(exarg_T *eap UNUSED) */ static void cs_kill_execute( - int i, /* cscope table index */ - char *cname) /* cscope database name */ + int i, // cscope table index + char *cname) // cscope database name { if (p_csverbose) { @@ -1612,17 +1611,16 @@ cs_make_vim_style_matches( char *search, char *tagstr) { - /* vim style is ctags: - * - * <tagstr>\t<filename>\t<linenum_or_search>"\t<extra> - * - * but as mentioned above, we'll always use the line number and - * put the search pattern (if one exists) as "extra" - * - * buf is used as part of vim's method of handling tags, and - * (i think) vim frees it when you pop your tags and get replaced - * by new ones on the tag stack. - */ + // vim style is ctags: + // + // <tagstr>\t<filename>\t<linenum_or_search>"\t<extra> + // + // but as mentioned above, we'll always use the line number and + // put the search pattern (if one exists) as "extra" + // + // buf is used as part of vim's method of handling tags, and + // (i think) vim frees it when you pop your tags and get replaced + // by new ones on the tag stack. char *buf; int amt; @@ -1644,7 +1642,7 @@ cs_make_vim_style_matches( } return buf; -} /* cs_make_vim_style_matches */ +} /* @@ -1716,13 +1714,13 @@ cs_manage_matches( case Print: cs_print_tags_priv(mp, cp, cnt); break; - default: /* should not reach here */ + default: // should not reach here iemsg(_("E570: fatal error in cs_manage_matches")); return NULL; } return p; -} /* cs_manage_matches */ +} /* @@ -1751,7 +1749,7 @@ cs_parse_results( return NULL; } - /* If the line's too long for the buffer, discard it. */ + // If the line's too long for the buffer, discard it. if ((p = strchr(buf, '\n')) == NULL) { while ((ch = getc(csinfo[cnumber].fr_fp)) != EOF && ch != '\n') @@ -1771,13 +1769,12 @@ cs_parse_results( return NULL; if ((*linenumber = strtok(NULL, (const char *)" ")) == NULL) return NULL; - *search = *linenumber + strlen(*linenumber) + 1; /* +1 to skip \0 */ + *search = *linenumber + strlen(*linenumber) + 1; // +1 to skip \0 - /* --- nvi --- - * If the file is older than the cscope database, that is, - * the database was built since the file was last modified, - * or there wasn't a search string, use the line number. - */ + // --- nvi --- + // If the file is older than the cscope database, that is, + // the database was built since the file was last modified, + // or there wasn't a search string, use the line number. if (strcmp(*search, "<unknown>") == 0) *search = NULL; @@ -1830,11 +1827,11 @@ cs_file_results(FILE *f, int *nummatches vim_free(context); vim_free(fullname); - } /* for all matches */ + } // for all matches (void)cs_read_prompt(i); - } /* for all cscope connections */ + } // for all cscope connections vim_free(buf); } #endif @@ -1892,24 +1889,23 @@ cs_fill_results( if (strcmp(cntx, "<global>") == 0) cntxts[totsofar] = NULL; else - /* note: if vim_strsave returns NULL, then the context - * will be "<global>", which is misleading. - */ + // note: if vim_strsave returns NULL, then the context + // will be "<global>", which is misleading. cntxts[totsofar] = (char *)vim_strsave((char_u *)cntx); if (matches[totsofar] != NULL) totsofar++; - } /* for all matches */ + } // for all matches (void)cs_read_prompt(i); - } /* for all cscope connections */ + } // for all cscope connections parse_out: if (totsofar == 0) { - /* No matches, free the arrays and return NULL in "*matches_p". */ + // No matches, free the arrays and return NULL in "*matches_p". VIM_CLEAR(matches); VIM_CLEAR(cntxts); } @@ -1918,10 +1914,12 @@ parse_out: *cntxts_p = cntxts; vim_free(buf); -} /* cs_fill_results */ +} -/* get the requested path components */ +/* + * get the requested path components + */ static char * cs_pathcomponents(char *path) { @@ -1956,7 +1954,7 @@ cs_print_tags_priv(char **matches, char { char *buf = NULL; char *t_buf; - int bufsize = 0; /* Track available bufsize */ + int bufsize = 0; // Track available bufsize int newsize = 0; char *ptag; char *fname, *lno, *extra, *tbuf; @@ -1991,7 +1989,7 @@ cs_print_tags_priv(char **matches, char vim_free(tbuf); - msg_puts_attr(_("\n # line"), HL_ATTR(HLF_T)); /* strlen is 7 */ + msg_puts_attr(_("\n # line"), HL_ATTR(HLF_T)); // strlen is 7 msg_advance(msg_col + 2); msg_puts_attr(_("filename / context / line\n"), HL_ATTR(HLF_T)); @@ -2000,10 +1998,9 @@ cs_print_tags_priv(char **matches, char { idx = i; - /* if we really wanted to, we could avoid this malloc and strcpy - * by parsing matches[i] on the fly and placing stuff into buf - * directly, but that's too much of a hassle - */ + // if we really wanted to, we could avoid this malloc and strcpy + // by parsing matches[i] on the fly and placing stuff into buf + // directly, but that's too much of a hassle if ((tbuf = alloc(strlen(matches[idx]) + 1)) == NULL) continue; (void)strcpy(tbuf, matches[idx]); @@ -2017,9 +2014,9 @@ cs_print_tags_priv(char **matches, char } extra = strtok(NULL, (const char *)"\t"); - lno[strlen(lno)-2] = '\0'; /* ignore ;" at the end */ + lno[strlen(lno)-2] = '\0'; // ignore ;" at the end - /* hopefully 'num' (num of matches) will be less than 10^16 */ + // hopefully 'num' (num of matches) will be less than 10^16 newsize = (int)(strlen(csfmt_str) + 16 + strlen(lno)); if (bufsize < newsize) { @@ -2035,14 +2032,14 @@ cs_print_tags_priv(char **matches, char } if (buf != NULL) { - /* csfmt_str = "%4d %6s "; */ + // csfmt_str = "%4d %6s "; (void)sprintf(buf, csfmt_str, num, lno); msg_puts_attr(buf, HL_ATTR(HLF_CM)); } msg_outtrans_long_attr((char_u *)cs_pathcomponents(fname), HL_ATTR(HLF_CM)); - /* compute the required space for the context */ + // compute the required space for the context if (cntxts[idx] != NULL) context = cntxts[idx]; else @@ -2065,7 +2062,7 @@ cs_print_tags_priv(char **matches, char { (void)sprintf(buf, cntxformat, context); - /* print the context only if it fits on the same line */ + // print the context only if it fits on the same line if (msg_col + (int)strlen(buf) >= (int)Columns) msg_putchar('\n'); msg_advance(12); @@ -2078,7 +2075,7 @@ cs_print_tags_priv(char **matches, char msg_outtrans_long_attr((char_u *)extra, 0); } - vim_free(tbuf); /* only after printing extra due to strtok use */ + vim_free(tbuf); // only after printing extra due to strtok use if (msg_col) msg_putchar('\n'); @@ -2086,15 +2083,15 @@ cs_print_tags_priv(char **matches, char ui_breakcheck(); if (got_int) { - got_int = FALSE; /* don't print any more matches */ + got_int = FALSE; // don't print any more matches break; } num++; - } /* for all matches */ + } // for all matches vim_free(buf); -} /* cs_print_tags_priv */ +} /* @@ -2104,7 +2101,7 @@ cs_print_tags_priv(char **matches, char cs_read_prompt(int i) { int ch; - char *buf = NULL; /* buffer for possible error message from cscope */ + char *buf = NULL; // buffer for possible error message from cscope int bufpos = 0; char *cs_emsg; int maxlen; @@ -2113,36 +2110,36 @@ cs_read_prompt(int i) int n; cs_emsg = _("E609: Cscope error: %s"); - /* compute maximum allowed len for Cscope error message */ + // compute maximum allowed len for Cscope error message maxlen = (int)(IOSIZE - strlen(cs_emsg)); for (;;) { while ((ch = getc(csinfo[i].fr_fp)) != EOF && ch != CSCOPE_PROMPT[0]) - /* if there is room and char is printable */ + // if there is room and char is printable if (bufpos < maxlen - 1 && vim_isprintc(ch)) { - if (buf == NULL) /* lazy buffer allocation */ + if (buf == NULL) // lazy buffer allocation buf = alloc(maxlen); if (buf != NULL) { - /* append character to the message */ + // append character to the message buf[bufpos++] = ch; buf[bufpos] = NUL; if (bufpos >= epromptlen && strcmp(&buf[bufpos - epromptlen], eprompt) == 0) { - /* remove eprompt from buf */ + // remove eprompt from buf buf[bufpos - epromptlen] = NUL; - /* print message to user */ + // print message to user (void)semsg(cs_emsg, buf); - /* send RETURN to cscope */ + // send RETURN to cscope (void)putc('\n', csinfo[i].to_fp); (void)fflush(csinfo[i].to_fp); - /* clear buf */ + // clear buf bufpos = 0; buf[bufpos] = NUL; } @@ -2159,7 +2156,7 @@ cs_read_prompt(int i) if (buf != NULL && buf[0] != NUL) (void)semsg(cs_emsg, buf); else if (p_csverbose) - cs_reading_emsg(i); /* don't have additional information */ + cs_reading_emsg(i); // don't have additional information cs_release_csp(i, TRUE); vim_free(buf); return CSCOPE_FAILURE; @@ -2173,8 +2170,8 @@ cs_read_prompt(int i) } if (ch == EOF) - continue; /* didn't find the prompt */ - break; /* did find the prompt */ + continue; // didn't find the prompt + break; // did find the prompt } vim_free(buf); @@ -2188,7 +2185,7 @@ cs_read_prompt(int i) static RETSIGTYPE sig_handler SIGDEFARG(sigarg) { - /* do nothing */ + // do nothing SIGRETURN; } #endif @@ -2217,7 +2214,7 @@ cs_release_csp(int i, int freefnpp) # if defined(HAVE_SIGACTION) struct sigaction sa, old; - /* Use sigaction() to limit the waiting time to two seconds. */ + // Use sigaction() to limit the waiting time to two seconds. sigemptyset(&sa.sa_mask); sa.sa_handler = sig_handler; # ifdef SA_NODEFER @@ -2226,28 +2223,28 @@ cs_release_csp(int i, int freefnpp) sa.sa_flags = 0; # endif sigaction(SIGALRM, &sa, &old); - alarm(2); /* 2 sec timeout */ + alarm(2); // 2 sec timeout - /* Block until cscope exits or until timer expires */ + // Block until cscope exits or until timer expires pid = waitpid(csinfo[i].pid, &pstat, 0); waitpid_errno = errno; - /* cancel pending alarm if still there and restore signal */ + // cancel pending alarm if still there and restore signal alarm(0); sigaction(SIGALRM, &old, NULL); # else int waited; - /* Can't use sigaction(), loop for two seconds. First yield the CPU - * to give cscope a chance to exit quickly. */ + // Can't use sigaction(), loop for two seconds. First yield the CPU + // to give cscope a chance to exit quickly. sleep(0); for (waited = 0; waited < 40; ++waited) { pid = waitpid(csinfo[i].pid, &pstat, WNOHANG); waitpid_errno = errno; if (pid != 0) - break; /* break unless the process is still running */ - mch_delay(50L, FALSE); /* sleep 50 ms */ + break; // break unless the process is still running + mch_delay(50L, FALSE); // sleep 50 ms } # endif /* @@ -2276,13 +2273,13 @@ cs_release_csp(int i, int freefnpp) sleep(0); for (waited = 0; waited < 40; ++waited) { - /* Check whether cscope process is still alive */ + // Check whether cscope process is still alive if (kill(csinfo[i].pid, 0) != 0) { - alive = FALSE; /* cscope process no longer exists */ + alive = FALSE; // cscope process no longer exists break; } - mch_delay(50L, FALSE); /* sleep 50ms */ + mch_delay(50L, FALSE); // sleep 50ms } } if (alive) @@ -2293,10 +2290,10 @@ cs_release_csp(int i, int freefnpp) } } } -#else /* !UNIX */ +#else // !UNIX if (csinfo[i].hProc != NULL) { - /* Give cscope a chance to exit normally */ + // Give cscope a chance to exit normally if (WaitForSingleObject(csinfo[i].hProc, 1000) == WAIT_TIMEOUT) TerminateProcess(csinfo[i].hProc, 0); CloseHandle(csinfo[i].hProc); @@ -2316,7 +2313,7 @@ cs_release_csp(int i, int freefnpp) } clear_csinfo(i); -} /* cs_release_csp */ +} /* @@ -2327,12 +2324,12 @@ cs_reset(exarg_T *eap UNUSED) { char **dblist = NULL, **pplist = NULL, **fllist = NULL; int i; - char buf[20]; /* for sprintf " (#%d)" */ + char buf[20]; // for sprintf " (#%d)" if (csinfo_size == 0) return CSCOPE_SUCCESS; - /* malloc our db and ppath list */ + // malloc our db and ppath list dblist = ALLOC_MULT(char *, csinfo_size); pplist = ALLOC_MULT(char *, csinfo_size); fllist = ALLOC_MULT(char *, csinfo_size); @@ -2353,7 +2350,7 @@ cs_reset(exarg_T *eap UNUSED) cs_release_csp(i, FALSE); } - /* rebuild the cscope connection list */ + // rebuild the cscope connection list for (i = 0; i < csinfo_size; i++) { if (dblist[i] != NULL) @@ -2361,10 +2358,9 @@ cs_reset(exarg_T *eap UNUSED) cs_add_common(dblist[i], pplist[i], fllist[i]); if (p_csverbose) { - /* don't use smsg_attr() because we want to display the - * connection number in the same line as - * "Added cscope database..." - */ + // don't use smsg_attr() because we want to display the + // connection number in the same line as + // "Added cscope database..." sprintf(buf, " (#%d)", i); msg_puts_attr(buf, HL_ATTR(HLF_R)); } @@ -2380,7 +2376,7 @@ cs_reset(exarg_T *eap UNUSED) if (p_csverbose) msg_attr(_("All cscope databases reset"), HL_ATTR(HLF_R) | MSG_HIST); return CSCOPE_SUCCESS; -} /* cs_reset */ +} /* @@ -2409,8 +2405,8 @@ cs_resolve_file(int i, char *name) len += (int)strlen(csinfo[i].ppath); else if (p_csre && csinfo[i].fname != NULL) { - /* If 'cscoperelative' is set and ppath is not set, use cscope.out - * path in path resolution. */ + // If 'cscoperelative' is set and ppath is not set, use cscope.out + // path in path resolution. csdir = alloc(MAXPATHL); if (csdir != NULL) { @@ -2421,9 +2417,9 @@ cs_resolve_file(int i, char *name) } } - /* Note/example: this won't work if the cscope output already starts - * "../.." and the prefix path is also "../..". if something like this - * happens, you are screwed up and need to fix how you're using cscope. */ + // Note/example: this won't work if the cscope output already starts + // "../.." and the prefix path is also "../..". if something like this + // happens, you are screwed up and need to fix how you're using cscope. if (csinfo[i].ppath != NULL && (strncmp(name, csinfo[i].ppath, strlen(csinfo[i].ppath)) != 0) && (name[0] != '/') @@ -2437,8 +2433,8 @@ cs_resolve_file(int i, char *name) } else if (csdir != NULL && csinfo[i].fname != NULL && *csdir != NUL) { - /* Check for csdir to be non empty to avoid empty path concatenated to - * cscope output. */ + // Check for csdir to be non empty to avoid empty path concatenated to + // cscope output. fullname = (char *)concat_fnames(csdir, (char_u *)name, TRUE); } else @@ -2481,7 +2477,7 @@ cs_show(exarg_T *eap UNUSED) wait_return(TRUE); return CSCOPE_SUCCESS; -} /* cs_show */ +} /* @@ -2498,7 +2494,7 @@ cs_end(void) csinfo_size = 0; } -#endif /* FEAT_CSCOPE */ +#endif // FEAT_CSCOPE #if defined(FEAT_EVAL) || defined(PROTO)
--- a/src/if_lua.c +++ b/src/if_lua.c @@ -15,8 +15,8 @@ #include <lualib.h> #include <lauxlib.h> -/* Only do the following when the feature is enabled. Needed for "make - * depend". */ +// Only do the following when the feature is enabled. Needed for "make +// depend". #if defined(FEAT_LUA) || defined(PROTO) #define LUAVIM_CHUNKNAME "vim chunk" @@ -45,9 +45,9 @@ static const char LUAVIM_FREE[] = "luaV_ static const char LUAVIM_LUAEVAL[] = "luaV_luaeval"; static const char LUAVIM_SETREF[] = "luaV_setref"; -/* most functions are closures with a cache table as first upvalue; - * get/setudata manage references to vim userdata in cache table through - * object pointers (light userdata) */ +// most functions are closures with a cache table as first upvalue; +// get/setudata manage references to vim userdata in cache table through +// object pointers (light userdata) #define luaV_getudata(L, v) \ lua_pushlightuserdata((L), (void *) (v)); \ lua_rawget((L), lua_upvalueindex(1)) @@ -94,7 +94,7 @@ static luaV_Funcref *luaV_pushfuncref(lu # define close_dll FreeLibrary #endif -/* lauxlib */ +// lauxlib #if LUA_VERSION_NUM <= 501 #define luaL_register dll_luaL_register #define luaL_prepbuffer dll_luaL_prepbuffer @@ -119,7 +119,7 @@ static luaV_Funcref *luaV_pushfuncref(lu #define luaL_buffinit dll_luaL_buffinit #define luaL_addlstring dll_luaL_addlstring #define luaL_pushresult dll_luaL_pushresult -/* lua */ +// lua #if LUA_VERSION_NUM <= 501 #define lua_tonumber dll_lua_tonumber #define lua_tointeger dll_lua_tointeger @@ -177,7 +177,7 @@ static luaV_Funcref *luaV_pushfuncref(lu #define lua_rawseti dll_lua_rawseti #define lua_setmetatable dll_lua_setmetatable #define lua_next dll_lua_next -/* libs */ +// libs #define luaopen_base dll_luaopen_base #define luaopen_table dll_luaopen_table #define luaopen_string dll_luaopen_string @@ -188,7 +188,7 @@ static luaV_Funcref *luaV_pushfuncref(lu #define luaopen_debug dll_luaopen_debug #define luaL_openlibs dll_luaL_openlibs -/* lauxlib */ +// lauxlib #if LUA_VERSION_NUM <= 501 void (*dll_luaL_register) (lua_State *L, const char *libname, const luaL_Reg *l); char *(*dll_luaL_prepbuffer) (luaL_Buffer *B); @@ -213,7 +213,7 @@ lua_State *(*dll_luaL_newstate) (void); void (*dll_luaL_buffinit) (lua_State *L, luaL_Buffer *B); void (*dll_luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); void (*dll_luaL_pushresult) (luaL_Buffer *B); -/* lua */ +// lua #if LUA_VERSION_NUM <= 501 lua_Number (*dll_lua_tonumber) (lua_State *L, int idx); lua_Integer (*dll_lua_tointeger) (lua_State *L, int idx); @@ -282,7 +282,7 @@ void (*dll_lua_rawseti) (lua_State *L, i #endif int (*dll_lua_setmetatable) (lua_State *L, int objindex); int (*dll_lua_next) (lua_State *L, int idx); -/* libs */ +// libs int (*dll_luaopen_base) (lua_State *L); int (*dll_luaopen_table) (lua_State *L); int (*dll_luaopen_string) (lua_State *L); @@ -300,7 +300,7 @@ typedef struct { } luaV_Reg; static const luaV_Reg luaV_dll[] = { - /* lauxlib */ + // lauxlib #if LUA_VERSION_NUM <= 501 {"luaL_register", (luaV_function) &dll_luaL_register}, {"luaL_prepbuffer", (luaV_function) &dll_luaL_prepbuffer}, @@ -325,7 +325,7 @@ static const luaV_Reg luaV_dll[] = { {"luaL_buffinit", (luaV_function) &dll_luaL_buffinit}, {"luaL_addlstring", (luaV_function) &dll_luaL_addlstring}, {"luaL_pushresult", (luaV_function) &dll_luaL_pushresult}, - /* lua */ + // lua #if LUA_VERSION_NUM <= 501 {"lua_tonumber", (luaV_function) &dll_lua_tonumber}, {"lua_tointeger", (luaV_function) &dll_lua_tointeger}, @@ -383,7 +383,7 @@ static const luaV_Reg luaV_dll[] = { {"lua_rawseti", (luaV_function) &dll_lua_rawseti}, {"lua_setmetatable", (luaV_function) &dll_lua_setmetatable}, {"lua_next", (luaV_function) &dll_lua_next}, - /* libs */ + // libs {"luaopen_base", (luaV_function) &dll_luaopen_base}, {"luaopen_table", (luaV_function) &dll_luaopen_table}, {"luaopen_string", (luaV_function) &dll_luaopen_string}, @@ -433,7 +433,7 @@ lua_link_init(char *libname, int verbose } return OK; } -#endif /* DYNAMIC_LUA */ +#endif // DYNAMIC_LUA #if defined(DYNAMIC_LUA) || defined(PROTO) int @@ -454,7 +454,7 @@ luaL_typeerror(lua_State *L, int narg, c #endif -/* ======= Internal ======= */ +// ======= Internal ======= static void luaV_newmetatable(lua_State *L, const char *tname) @@ -470,14 +470,14 @@ luaV_toudata(lua_State *L, int ud, const { void *p = lua_touserdata(L, ud); - if (p != NULL) /* value is userdata? */ + if (p != NULL) // value is userdata? { - if (lua_getmetatable(L, ud)) /* does it have a metatable? */ + if (lua_getmetatable(L, ud)) // does it have a metatable? { - luaV_getfield(L, tname); /* get metatable */ - if (lua_rawequal(L, -1, -2)) /* MTs match? */ + luaV_getfield(L, tname); // get metatable + if (lua_rawequal(L, -1, -2)) // MTs match? { - lua_pop(L, 2); /* MTs */ + lua_pop(L, 2); // MTs return p; } } @@ -643,8 +643,10 @@ luaV_totypval(lua_State *L, int pos, typ return status; } -/* similar to luaL_addlstring, but replaces \0 with \n if toline and - * \n with \0 otherwise */ +/* + * similar to luaL_addlstring, but replaces \0 with \n if toline and + * \n with \0 otherwise + */ static void luaV_addlstring(luaL_Buffer *b, const char *s, size_t l, int toline) { @@ -683,8 +685,10 @@ luaV_toline(lua_State *L, int pos) return (char_u *) lua_tostring(L, -1); } -/* pops a string s from the top of the stack and calls mf(t) for pieces t of - * s separated by newlines */ +/* + * pops a string s from the top of the stack and calls mf(t) for pieces t of + * s separated by newlines + */ static void luaV_msgfunc(lua_State *L, msgfunc_T mf) { @@ -694,18 +698,18 @@ luaV_msgfunc(lua_State *L, msgfunc_T mf) luaL_buffinit(L, &b); luaV_addlstring(&b, s, l, 0); luaL_pushresult(&b); - /* break string */ + // break string p = s = lua_tolstring(L, -1, &l); while (l--) { - if (*p++ == '\0') /* break? */ + if (*p++ == '\0') // break? { mf((char_u *) s); s = p; } } mf((char_u *) s); - lua_pop(L, 2); /* original and modified strings */ + lua_pop(L, 2); // original and modified strings } #define luaV_newtype(typ,tname,luatyp,luatname) \ @@ -748,15 +752,15 @@ luaV_msgfunc(lua_State *L, msgfunc_T mf) return 1; \ } -/* ======= List type ======= */ +// ======= List type ======= static luaV_List * luaV_newlist(lua_State *L, list_T *lis) { luaV_List *l = (luaV_List *) lua_newuserdata(L, sizeof(luaV_List)); *l = lis; - lis->lv_refcount++; /* reference in Lua */ - luaV_setudata(L, lis); /* cache[lis] = udata */ + lis->lv_refcount++; // reference in Lua + luaV_setudata(L, lis); // cache[lis] = udata luaV_getfield(L, LUAVIM_LIST); lua_setmetatable(L, -2); return l; @@ -788,7 +792,7 @@ luaV_list_iter(lua_State *L) luaV_list_call(lua_State *L) { list_T *l = luaV_unbox(L, luaV_List, 1); - lua_pushvalue(L, lua_upvalueindex(1)); /* pass cache table along */ + lua_pushvalue(L, lua_upvalueindex(1)); // pass cache table along lua_pushlightuserdata(L, (void *) l->lv_first); lua_pushcclosure(L, luaV_list_iter, 2); return 1; @@ -798,7 +802,7 @@ luaV_list_call(lua_State *L) luaV_list_index(lua_State *L) { list_T *l = luaV_unbox(L, luaV_List, 1); - if (lua_isnumber(L, 2)) /* list item? */ + if (lua_isnumber(L, 2)) // list item? { listitem_T *li = list_find(l, (long) luaL_checkinteger(L, 2)); if (li == NULL) @@ -806,7 +810,7 @@ luaV_list_index(lua_State *L) else luaV_pushtypval(L, &li->li_tv); } - else if (lua_isstring(L, 2)) /* method? */ + else if (lua_isstring(L, 2)) // method? { const char *s = lua_tostring(L, 2); if (strncmp(s, "add", 3) == 0 @@ -833,7 +837,7 @@ luaV_list_newindex(lua_State *L) luaL_error(L, "list is locked"); li = list_find(l, n); if (li == NULL) return 0; - if (lua_isnil(L, 3)) /* remove? */ + if (lua_isnil(L, 3)) // remove? { vimlist_remove(l, li, li); clear_tv(&li->li_tv); @@ -904,15 +908,15 @@ static const luaL_Reg luaV_List_mt[] = { }; -/* ======= Dict type ======= */ +// ======= Dict type ======= static luaV_Dict * luaV_newdict(lua_State *L, dict_T *dic) { luaV_Dict *d = (luaV_Dict *) lua_newuserdata(L, sizeof(luaV_Dict)); *d = dic; - dic->dv_refcount++; /* reference in Lua */ - luaV_setudata(L, dic); /* cache[dic] = udata */ + dic->dv_refcount++; // reference in Lua + luaV_setudata(L, dic); // cache[dic] = udata luaV_getfield(L, LUAVIM_DICT); lua_setmetatable(L, -2); return d; @@ -956,9 +960,9 @@ luaV_dict_call(lua_State *L) { dict_T *d = luaV_unbox(L, luaV_Dict, 1); hashtab_T *ht = &d->dv_hashtab; - lua_pushvalue(L, lua_upvalueindex(1)); /* pass cache table along */ + lua_pushvalue(L, lua_upvalueindex(1)); // pass cache table along lua_pushlightuserdata(L, (void *) ht->ht_array); - lua_pushinteger(L, ht->ht_used); /* # remaining items */ + lua_pushinteger(L, ht->ht_used); // # remaining items lua_pushcclosure(L, luaV_dict_iter, 3); return 1; } @@ -975,10 +979,10 @@ luaV_dict_index(lua_State *L) else { luaV_pushtypval(L, &di->di_tv); - if (di->di_tv.v_type == VAR_FUNC) /* funcref? */ + if (di->di_tv.v_type == VAR_FUNC) // funcref? { luaV_Funcref *f = (luaV_Funcref *) lua_touserdata(L, -1); - f->self = d; /* keep "self" reference */ + f->self = d; // keep "self" reference d->dv_refcount++; } } @@ -999,14 +1003,14 @@ luaV_dict_newindex(lua_State *L) return 0; if (*key == NUL) luaL_error(L, "empty key"); - if (!lua_isnil(L, 3)) /* read value? */ + if (!lua_isnil(L, 3)) // read value? { luaV_checktypval(L, 3, &v, "setting dict item"); if (d->dv_scope == VAR_DEF_SCOPE && v.v_type == VAR_FUNC) luaL_error(L, "cannot assign funcref to builtin scope"); } di = dict_find(d, key, -1); - if (di == NULL) /* non-existing key? */ + if (di == NULL) // non-existing key? { if (lua_isnil(L, 3)) return 0; @@ -1021,7 +1025,7 @@ luaV_dict_newindex(lua_State *L) } else clear_tv(&di->di_tv); - if (lua_isnil(L, 3)) /* remove? */ + if (lua_isnil(L, 3)) // remove? { hashitem_T *hi = hash_find(&d->dv_hashtab, di->di_key); hash_remove(&d->dv_hashtab, hi); @@ -1045,15 +1049,15 @@ static const luaL_Reg luaV_Dict_mt[] = { }; -/* ======= Blob type ======= */ +// ======= Blob type ======= static luaV_Blob * luaV_newblob(lua_State *L, blob_T *blo) { luaV_Blob *b = (luaV_Blob *) lua_newuserdata(L, sizeof(luaV_Blob)); *b = blo; - blo->bv_refcount++; /* reference in Lua */ - luaV_setudata(L, blo); /* cache[blo] = udata */ + blo->bv_refcount++; // reference in Lua + luaV_setudata(L, blo); // cache[blo] = udata luaV_getfield(L, LUAVIM_BLOB); lua_setmetatable(L, -2); return b; @@ -1163,7 +1167,7 @@ static const luaL_Reg luaV_Blob_mt[] = { }; -/* ======= Funcref type ======= */ +// ======= Funcref type ======= static luaV_Funcref * luaV_newfuncref(lua_State *L, char_u *name) @@ -1202,7 +1206,7 @@ luaV_funcref_gc(lua_State *L) return 0; } -/* equivalent to string(funcref) */ +// equivalent to string(funcref) static int luaV_funcref_len(lua_State *L) { @@ -1254,7 +1258,7 @@ static const luaL_Reg luaV_Funcref_mt[] }; -/* ======= Buffer type ======= */ +// ======= Buffer type ======= luaV_newtype(buf_T, buffer, luaV_Buffer, LUAVIM_BUFFER) luaV_pushtype(buf_T, buffer, luaV_Buffer) @@ -1295,7 +1299,7 @@ luaV_buffer_index(lua_State *L) ? "" : (char *) b->b_ffname); else if (strncmp(s, "number", 6) == 0) lua_pushinteger(L, b->b_fnum); - /* methods */ + // methods else if (strncmp(s, "insert", 6) == 0 || strncmp(s, "next", 4) == 0 || strncmp(s, "previous", 8) == 0 @@ -1322,7 +1326,7 @@ luaV_buffer_newindex(lua_State *L) #endif if (n < 1 || n > b->b_ml.ml_line_count) luaL_error(L, "invalid line number"); - if (lua_isnil(L, 3)) /* delete line */ + if (lua_isnil(L, 3)) // delete line { buf_T *buf = curbuf; curbuf = b; @@ -1339,7 +1343,7 @@ luaV_buffer_newindex(lua_State *L) else { deleted_lines_mark(n, 1L); - if (b == curwin->w_buffer) /* fix cursor in current window? */ + if (b == curwin->w_buffer) // fix cursor in current window? { if (curwin->w_cursor.lnum >= n) { @@ -1356,7 +1360,7 @@ luaV_buffer_newindex(lua_State *L) } curbuf = buf; } - else if (lua_isstring(L, 3)) /* update line */ + else if (lua_isstring(L, 3)) // update line { buf_T *buf = curbuf; curbuf = b; @@ -1392,10 +1396,10 @@ luaV_buffer_insert(lua_State *L) #ifdef HAVE_SANDBOX luaV_checksandbox(L); #endif - /* fix insertion line */ + // fix insertion line if (n < 0) n = 0; if (n > last) n = last; - /* insert */ + // insert buf = curbuf; curbuf = b; if (u_save(n, n + 1) == FAIL) @@ -1456,7 +1460,7 @@ static const luaL_Reg luaV_Buffer_mt[] = }; -/* ======= Window type ======= */ +// ======= Window type ======= luaV_newtype(win_T, window, luaV_Window, LUAVIM_WINDOW) luaV_pushtype(win_T, window, luaV_Window) @@ -1486,7 +1490,7 @@ luaV_window_index(lua_State *L) lua_pushinteger(L, w->w_width); else if (strncmp(s, "height", 6) == 0) lua_pushinteger(L, w->w_height); - /* methods */ + // methods else if (strncmp(s, "next", 4) == 0 || strncmp(s, "previous", 8) == 0 || strncmp(s, "isvalid", 7) == 0) @@ -1588,12 +1592,12 @@ static const luaL_Reg luaV_Window_mt[] = }; -/* ======= Vim module ======= */ +// ======= Vim module ======= static int luaV_print(lua_State *L) { - int i, n = lua_gettop(L); /* nargs */ + int i, n = lua_gettop(L); // nargs const char *s; size_t l; luaL_Buffer b; @@ -1601,13 +1605,13 @@ luaV_print(lua_State *L) lua_getglobal(L, "tostring"); for (i = 1; i <= n; i++) { - lua_pushvalue(L, -1); /* tostring */ - lua_pushvalue(L, i); /* arg */ + lua_pushvalue(L, -1); // tostring + lua_pushvalue(L, i); // arg lua_call(L, 1, 1); s = lua_tolstring(L, -1, &l); if (s == NULL) return luaL_error(L, "cannot convert to string"); - if (i > 1) luaL_addchar(&b, ' '); /* use space instead of tab */ + if (i > 1) luaL_addchar(&b, ' '); // use space instead of tab luaV_addlstring(&b, s, l, 0); lua_pop(L, 1); } @@ -1623,22 +1627,22 @@ luaV_debug(lua_State *L) lua_settop(L, 0); lua_getglobal(L, "vim"); lua_getfield(L, -1, "eval"); - lua_remove(L, -2); /* vim.eval at position 1 */ + lua_remove(L, -2); // vim.eval at position 1 for (;;) { const char *input; size_t l; - lua_pushvalue(L, 1); /* vim.eval */ + lua_pushvalue(L, 1); // vim.eval lua_pushliteral(L, "input('lua_debug> ')"); - lua_call(L, 1, 1); /* return string */ + lua_call(L, 1, 1); // return string input = lua_tolstring(L, -1, &l); if (l == 0 || strcmp(input, "cont") == 0) return 0; - msg_putchar('\n'); /* avoid outputting on input line */ + msg_putchar('\n'); // avoid outputting on input line if (luaL_loadbuffer(L, input, l, "=(debug command)") || lua_pcall(L, 0, 0, 0)) luaV_emsg(L); - lua_settop(L, 1); /* remove eventual returns, but keep vim.eval */ + lua_settop(L, 1); // remove eventual returns, but keep vim.eval } } @@ -1688,7 +1692,7 @@ luaV_list(lua_State *L) else { luaV_newlist(L, l); - if (initarg) /* traverse table to init list */ + if (initarg) // traverse table to init list { int notnil, i = 0; typval_T v; @@ -1702,7 +1706,7 @@ luaV_list(lua_State *L) list_append_tv(l, &v); clear_tv(&v); } - lua_pop(L, 1); /* value */ + lua_pop(L, 1); // value } while (notnil); } } @@ -1723,7 +1727,7 @@ luaV_dict(lua_State *L) else { luaV_newdict(L, d); - if (initarg) /* traverse table to init dict */ + if (initarg) // traverse table to init dict { lua_pushnil(L); while (lua_next(L, 1)) @@ -1732,7 +1736,7 @@ luaV_dict(lua_State *L) dictitem_T *di; typval_T v; - lua_pushvalue(L, -2); /* dup key in case it's a number */ + lua_pushvalue(L, -2); // dup key in case it's a number key = (char_u *) lua_tostring(L, -1); if (key == NULL) { @@ -1741,7 +1745,7 @@ luaV_dict(lua_State *L) } if (*key == NUL) luaL_error(L, "table has empty key"); - luaV_checktypval(L, -2, &v, "vim.dict"); /* value */ + luaV_checktypval(L, -2, &v, "vim.dict"); // value di = dictitem_alloc(key); if (di == NULL || dict_add(d, di) == FAIL) { @@ -1751,7 +1755,7 @@ luaV_dict(lua_State *L) } copy_tv(&v, &di->di_tv); clear_tv(&v); - lua_pop(L, 2); /* key copy and value */ + lua_pop(L, 2); // key copy and value } } } @@ -1789,7 +1793,7 @@ luaV_blob(lua_State *L) luaV_funcref(lua_State *L) { const char *name = luaL_checkstring(L, 1); - /* note: not checking if function exists (needs function_exists) */ + // note: not checking if function exists (needs function_exists) if (name == NULL || *name == NUL || VIM_ISDIGIT(*name)) luaL_error(L, "invalid function name: %s", name); luaV_newfuncref(L, (char_u *) name); @@ -1800,9 +1804,9 @@ luaV_funcref(lua_State *L) luaV_buffer(lua_State *L) { buf_T *buf; - if (lua_isstring(L, 1)) /* get by number or name? */ + if (lua_isstring(L, 1)) // get by number or name? { - if (lua_isnumber(L, 1)) /* by number? */ + if (lua_isnumber(L, 1)) // by number? { int n = lua_tointeger(L, 1); FOR_ALL_BUFFERS(buf) @@ -1825,7 +1829,7 @@ luaV_buffer(lua_State *L) } } else - buf = (lua_toboolean(L, 1)) ? firstbuf : curbuf; /* first buffer? */ + buf = (lua_toboolean(L, 1)) ? firstbuf : curbuf; // first buffer? luaV_pushbuffer(L, buf); return 1; } @@ -1834,14 +1838,14 @@ luaV_buffer(lua_State *L) luaV_window(lua_State *L) { win_T *win; - if (lua_isnumber(L, 1)) /* get by number? */ + if (lua_isnumber(L, 1)) // get by number? { int n = lua_tointeger(L, 1); for (win = firstwin; win != NULL; win = win->w_next, n--) if (n == 1) break; } else - win = (lua_toboolean(L, 1)) ? firstwin : curwin; /* first window? */ + win = (lua_toboolean(L, 1)) ? firstwin : curwin; // first window? luaV_pushwindow(L, win); return 1; } @@ -1862,7 +1866,7 @@ luaV_open(lua_State *L) luaV_type(lua_State *L) { luaL_checkany(L, 1); - if (lua_type(L, 1) == LUA_TUSERDATA) /* check vim udata? */ + if (lua_type(L, 1) == LUA_TUSERDATA) // check vim udata? { lua_settop(L, 1); if (lua_getmetatable(L, 1)) @@ -1905,7 +1909,7 @@ luaV_type(lua_State *L) } } } - lua_pushstring(L, luaL_typename(L, 1)); /* fallback */ + lua_pushstring(L, luaL_typename(L, 1)); // fallback return 1; } @@ -1925,7 +1929,9 @@ static const luaL_Reg luaV_module[] = { {NULL, NULL} }; -/* for freeing list, dict, buffer and window objects; lightuserdata as arg */ +/* + * for freeing list, dict, buffer and window objects; lightuserdata as arg + */ static int luaV_free(lua_State *L) { @@ -1947,13 +1953,13 @@ luaV_luaeval(lua_State *L) luaL_addlstring(&b, str, l); luaL_pushresult(&b); str = lua_tolstring(L, -1, &l); - if (luaL_loadbuffer(L, str, l, LUAVIM_EVALNAME)) /* compile error? */ + if (luaL_loadbuffer(L, str, l, LUAVIM_EVALNAME)) // compile error? { luaV_emsg(L); return 0; } luaV_pushtypval(L, arg); - if (lua_pcall(L, 1, 1, 0)) /* running error? */ + if (lua_pcall(L, 1, 1, 0)) // running error? { luaV_emsg(L); return 0; @@ -2004,36 +2010,36 @@ luaV_setref(lua_State *L) static int luaopen_vim(lua_State *L) { - /* set cache table */ + // set cache table lua_newtable(L); lua_newtable(L); lua_pushstring(L, "v"); lua_setfield(L, -2, "__mode"); - lua_setmetatable(L, -2); /* cache is weak-valued */ - /* print */ + lua_setmetatable(L, -2); // cache is weak-valued + // print lua_pushcfunction(L, luaV_print); lua_setglobal(L, "print"); - /* debug.debug */ + // debug.debug lua_getglobal(L, "debug"); lua_pushcfunction(L, luaV_debug); lua_setfield(L, -2, "debug"); lua_pop(L, 1); - /* free */ + // free lua_pushlightuserdata(L, (void *) LUAVIM_FREE); - lua_pushvalue(L, 1); /* cache table */ + lua_pushvalue(L, 1); // cache table lua_pushcclosure(L, luaV_free, 1); lua_rawset(L, LUA_REGISTRYINDEX); - /* luaeval */ + // luaeval lua_pushlightuserdata(L, (void *) LUAVIM_LUAEVAL); - lua_pushvalue(L, 1); /* cache table */ + lua_pushvalue(L, 1); // cache table lua_pushcclosure(L, luaV_luaeval, 1); lua_rawset(L, LUA_REGISTRYINDEX); - /* setref */ + // setref lua_pushlightuserdata(L, (void *) LUAVIM_SETREF); - lua_pushvalue(L, 1); /* cache table */ + lua_pushvalue(L, 1); // cache table lua_pushcclosure(L, luaV_setref, 1); lua_rawset(L, LUA_REGISTRYINDEX); - /* register */ + // register luaV_newmetatable(L, LUAVIM_LIST); lua_pushvalue(L, 1); luaV_openlib(L, luaV_List_mt, 1); @@ -2047,13 +2053,13 @@ luaopen_vim(lua_State *L) lua_pushvalue(L, 1); luaV_openlib(L, luaV_Funcref_mt, 1); luaV_newmetatable(L, LUAVIM_BUFFER); - lua_pushvalue(L, 1); /* cache table */ + lua_pushvalue(L, 1); // cache table luaV_openlib(L, luaV_Buffer_mt, 1); luaV_newmetatable(L, LUAVIM_WINDOW); - lua_pushvalue(L, 1); /* cache table */ + lua_pushvalue(L, 1); // cache table luaV_openlib(L, luaV_Window_mt, 1); - lua_newtable(L); /* vim table */ - lua_pushvalue(L, 1); /* cache table */ + lua_newtable(L); // vim table + lua_pushvalue(L, 1); // cache table luaV_openlib(L, luaV_module, 1); lua_setglobal(L, LUAVIM_NAME); return 0; @@ -2063,8 +2069,8 @@ luaopen_vim(lua_State *L) luaV_newstate(void) { lua_State *L = luaL_newstate(); - luaL_openlibs(L); /* core libs */ - lua_pushcfunction(L, luaopen_vim); /* vim */ + luaL_openlibs(L); // core libs + lua_pushcfunction(L, luaopen_vim); // vim lua_call(L, 0, 0); return L; } @@ -2077,11 +2083,11 @@ luaV_setrange(lua_State *L, int line1, i lua_setfield(L, -2, "firstline"); lua_pushinteger(L, line2); lua_setfield(L, -2, "lastline"); - lua_pop(L, 1); /* vim table */ + lua_pop(L, 1); // vim table } -/* ======= Interface ======= */ +// ======= Interface ======= static lua_State *L = NULL; @@ -2121,7 +2127,9 @@ lua_end(void) } } -/* ex commands */ +/* + * ex commands + */ void ex_lua(exarg_T *eap) { @@ -2156,48 +2164,48 @@ ex_luado(exarg_T *eap) } luaV_setrange(L, eap->line1, eap->line2); luaL_buffinit(L, &b); - luaL_addlstring(&b, "return function(line, linenr) ", 30); /* header */ + luaL_addlstring(&b, "return function(line, linenr) ", 30); // header luaL_addlstring(&b, s, strlen(s)); - luaL_addlstring(&b, " end", 4); /* footer */ + luaL_addlstring(&b, " end", 4); // footer luaL_pushresult(&b); s = lua_tolstring(L, -1, &len); if (luaL_loadbuffer(L, s, len, LUAVIM_CHUNKNAME)) { luaV_emsg(L); - lua_pop(L, 1); /* function body */ + lua_pop(L, 1); // function body return; } lua_call(L, 0, 1); - lua_replace(L, -2); /* function -> body */ + lua_replace(L, -2); // function -> body for (l = eap->line1; l <= eap->line2; l++) { - /* Check the line number, the command my have deleted lines. */ + // Check the line number, the command my have deleted lines. if (l > curbuf->b_ml.ml_line_count) break; - lua_pushvalue(L, -1); /* function */ - luaV_pushline(L, curbuf, l); /* current line as arg */ - lua_pushinteger(L, l); /* current line number as arg */ + lua_pushvalue(L, -1); // function + luaV_pushline(L, curbuf, l); // current line as arg + lua_pushinteger(L, l); // current line number as arg if (lua_pcall(L, 2, 1, 0)) { luaV_emsg(L); break; } - /* Catch the command switching to another buffer. */ + // Catch the command switching to another buffer. if (curbuf != was_curbuf) break; - if (lua_isstring(L, -1)) /* update line? */ + if (lua_isstring(L, -1)) // update line? { #ifdef HAVE_SANDBOX luaV_checksandbox(L); #endif ml_replace(l, luaV_toline(L, -1), TRUE); changed_bytes(l, 0); - lua_pop(L, 1); /* result from luaV_toline */ + lua_pop(L, 1); // result from luaV_toline } - lua_pop(L, 1); /* line */ + lua_pop(L, 1); // line } - lua_pop(L, 1); /* function */ + lua_pop(L, 1); // function check_cursor(); update_screen(NOT_VALID); } @@ -2247,12 +2255,12 @@ set_ref_in_lua(int copyID) if (lua_isopen()) { luaV_getfield(L, LUAVIM_SETREF); - /* call the function with 1 arg, getting 1 result back */ + // call the function with 1 arg, getting 1 result back lua_pushinteger(L, copyID); lua_call(L, 1, 1); - /* get the result */ + // get the result aborted = lua_tointeger(L, -1); - /* pop result off the stack */ + // pop result off the stack lua_pop(L, 1); } return aborted;
--- a/src/if_mzsch.c +++ b/src/if_mzsch.c @@ -25,8 +25,8 @@ #include "if_mzsch.h" -/* Only do the following when the feature is enabled. Needed for "make - * depend". */ +// Only do the following when the feature is enabled. Needed for "make +// depend". #if defined(FEAT_MZSCHEME) || defined(PROTO) #ifdef PROTO @@ -63,7 +63,7 @@ typedef int HINSTANCE; # define TRAMPOLINED_MZVIM_STARTUP #endif -/* Base data structures */ +// Base data structures #define SCHEME_VIMBUFFERP(obj) SAME_TYPE(SCHEME_TYPE(obj), mz_buffer_type) #define SCHEME_VIMWINDOWP(obj) SAME_TYPE(SCHEME_TYPE(obj), mz_window_type) @@ -90,7 +90,7 @@ typedef struct { Scheme_Closed_Prim *prim; char *name; - int mina; /* arity information */ + int mina; // arity information int maxa; } Vim_Prim; @@ -115,12 +115,12 @@ static Scheme_Object *sandbox_file_guard static Scheme_Object *sandbox_network_guard(int, Scheme_Object **); static void sandbox_check(void); #endif -/* Buffer-related commands */ +// Buffer-related commands static Scheme_Object *buffer_new(buf_T *buf); static Scheme_Object *get_buffer_by_num(void *, int, Scheme_Object **); static vim_mz_buffer *get_vim_curr_buffer(void); -/* Window-related commands */ +// Window-related commands static Scheme_Object *window_new(win_T *win); static vim_mz_window *get_vim_curr_window(void); @@ -182,13 +182,11 @@ static int buffer_mark_proc(void *obj) } static int buffer_fixup_proc(void *obj) { - /* apparently not needed as the object will be uncollectable while - * the buffer is alive - */ - /* - vim_mz_buffer* buf = (vim_mz_buffer*) obj; - buf->buf->b_mzscheme_ref = GC_fixup_self(obj); - */ + // apparently not needed as the object will be uncollectable while + // the buffer is alive + // vim_mz_buffer* buf = (vim_mz_buffer*) obj; + // buf->buf->b_mzscheme_ref = GC_fixup_self(obj); + return buffer_size_proc(obj); } static int window_size_proc(void *obj UNUSED) @@ -201,18 +199,16 @@ static int window_mark_proc(void *obj) } static int window_fixup_proc(void *obj) { - /* apparently not needed as the object will be uncollectable while - * the window is alive - */ - /* - vim_mz_window* win = (vim_mz_window*) obj; - win->win->w_mzscheme_ref = GC_fixup_self(obj); - */ + // apparently not needed as the object will be uncollectable while + // the window is alive + // vim_mz_window* win = (vim_mz_window*) obj; + // win->win->w_mzscheme_ref = GC_fixup_self(obj); + // return window_size_proc(obj); } -/* with precise GC, w_mzscheme_ref and b_mzscheme_ref are immobile boxes - * containing pointers to a window/buffer - * with conservative GC these are simply pointers*/ +// with precise GC, w_mzscheme_ref and b_mzscheme_ref are immobile boxes +// containing pointers to a window/buffer +// with conservative GC these are simply pointers # define WINDOW_REF(win) *(vim_mz_window **)((win)->w_mzscheme_ref) # define BUFFER_REF(buf) *(vim_mz_buffer **)((buf)->b_mzscheme_ref) #else @@ -378,16 +374,16 @@ static void (*dll_scheme_register_embedd static void (*dll_scheme_set_config_path)(Scheme_Object *p); # endif -#if defined(DYNAMIC_MZSCHEME) /* not when defined(PROTO) */ - -/* arrays are imported directly */ +#if defined(DYNAMIC_MZSCHEME) // not when defined(PROTO) + +// arrays are imported directly # define scheme_eof dll_scheme_eof # define scheme_false dll_scheme_false # define scheme_void dll_scheme_void # define scheme_null dll_scheme_null # define scheme_true dll_scheme_true -/* pointers are GetProceAddress'ed as pointers to pointer */ +// pointers are GetProceAddress'ed as pointers to pointer #if !defined(USE_THREAD_LOCAL) && !defined(LINK_EXTENSIONS_BY_TABLE) # define scheme_current_thread (*dll_scheme_current_thread_ptr) # endif @@ -395,7 +391,7 @@ static void (*dll_scheme_set_config_path # define scheme_console_output (*dll_scheme_console_output_ptr) # define scheme_notify_multithread (*dll_scheme_notify_multithread_ptr) -/* and functions in a usual way */ +// and functions in a usual way # define GC_malloc dll_GC_malloc # define GC_malloc_atomic dll_GC_malloc_atomic @@ -504,7 +500,7 @@ static void (*dll_scheme_set_config_path # if MZSCHEME_VERSION_MAJOR >= 500 # if defined(IMPLEMENT_THREAD_LOCAL_VIA_WIN_TLS) || defined(IMPLEMENT_THREAD_LOCAL_EXTERNALLY_VIA_PROC) -/* define as function for macro in schthread.h */ +// define as function for macro in schthread.h Thread_Local_Variables * scheme_external_get_thread_local_variables(void) { @@ -735,7 +731,7 @@ dynamic_mzscheme_end(void) hMzGC = 0; } } -#endif /* DYNAMIC_MZSCHEME */ +#endif // DYNAMIC_MZSCHEME #if MZSCHEME_VERSION_MAJOR < 299 # define GUARANTEED_STRING_ARG(proc, num) GUARANTEE_STRING(proc, num) @@ -760,13 +756,13 @@ guaranteed_byte_string_arg(char *proc, i } else scheme_wrong_type(proc, "string", num, argc, argv); - /* unreachable */ + // unreachable return scheme_void; } # define GUARANTEED_STRING_ARG(proc, num) guaranteed_byte_string_arg(proc, num, argc, argv) #endif -/* need to put it here for dynamic stuff to work */ +// need to put it here for dynamic stuff to work #if defined(INCLUDE_MZSCHEME_BASE) # include "mzscheme_base.c" #endif @@ -786,16 +782,16 @@ static int disabled = FALSE; #endif static int load_base_module_failed = FALSE; -/* global environment */ +// global environment static Scheme_Env *environment = NULL; -/* output/error handlers */ +// output/error handlers static Scheme_Object *curout = NULL; static Scheme_Object *curerr = NULL; -/* exn:vim exception */ +// exn:vim exception static Scheme_Object *exn_catching_apply = NULL; static Scheme_Object *exn_p = NULL; static Scheme_Object *exn_message = NULL; -static Scheme_Object *vim_exn = NULL; /* Vim Error exception */ +static Scheme_Object *vim_exn = NULL; // Vim Error exception #if !defined(MZ_PRECISE_GC) || MZSCHEME_VERSION_MAJOR < 400 static void *stack_base = NULL; @@ -804,7 +800,7 @@ static void *stack_base = NULL; static long range_start; static long range_end; -/* MzScheme threads scheduling stuff */ +// MzScheme threads scheduling stuff static int mz_threads_allow = 0; #if defined(FEAT_GUI_MSWIN) @@ -822,11 +818,11 @@ static EventLoopTimerRef timer_id = NULL static EventLoopTimerUPP timerUPP; #endif -#if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL) /* Win32 console and Unix */ +#if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL) // Win32 console and Unix void mzvim_check_threads(void) { - /* Last time MzScheme threads were scheduled */ + // Last time MzScheme threads were scheduled static time_t mz_last_time = 0; if (mz_threads_allow && p_mzq > 0) @@ -846,7 +842,7 @@ mzvim_check_threads(void) static void setup_timer(void); static void remove_timer(void); -/* timers are presented in GUI only */ +// timers are presented in GUI only # if defined(FEAT_GUI_MSWIN) static void CALLBACK timer_proc(HWND hwnd UNUSED, UINT uMsg UNUSED, UINT_PTR idEvent UNUSED, DWORD dwTime UNUSED) @@ -863,9 +859,9 @@ timer_proc(EventLoopTimerRef theTimer UN { scheme_check_threads(); # if defined(FEAT_GUI_GTK) - return TRUE; /* continue receiving notifications */ + return TRUE; // continue receiving notifications # elif defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) - /* renew timeout */ + // renew timeout if (mz_threads_allow && p_mzq > 0) timer_id = XtAppAddTimeOut(app_context, p_mzq, timer_proc, NULL); @@ -913,7 +909,7 @@ mzvim_reset_timer(void) setup_timer(); } -#endif /* MZSCHEME_GUI_THREADS */ +#endif // MZSCHEME_GUI_THREADS static void notify_multithread(int on) @@ -930,7 +926,7 @@ notify_multithread(int on) void mzscheme_end(void) { - /* We can not unload the DLL. Racket's thread might be still alive. */ + // We can not unload the DLL. Racket's thread might be still alive. #if 0 #ifdef DYNAMIC_MZSCHEME dynamic_mzscheme_end(); @@ -987,7 +983,7 @@ mzscheme_main(void) mzscheme_env_main(Scheme_Env *env, int argc UNUSED, char **argv UNUSED) { #ifdef TRAMPOLINED_MZVIM_STARTUP - /* Scheme has created the environment for us */ + // Scheme has created the environment for us environment = env; #else # ifdef MZ_PRECISE_GC @@ -1003,7 +999,7 @@ mzscheme_env_main(Scheme_Env *env, int a #endif vim_main2(); - /* not reached, vim_main2() will loop until exit() */ + // not reached, vim_main2() will loop until exit() return 0; } @@ -1030,7 +1026,7 @@ startup_mzscheme(void) #endif #ifndef TRAMPOLINED_MZVIM_STARTUP - /* in newer versions of precise GC the initial env has been created */ + // in newer versions of precise GC the initial env has been created environment = scheme_basic_env(); #endif @@ -1045,11 +1041,11 @@ startup_mzscheme(void) MZ_GC_CHECK(); #ifdef INCLUDE_MZSCHEME_BASE - /* invoke function from generated and included mzscheme_base.c */ + // invoke function from generated and included mzscheme_base.c declare_modules(environment); #endif - /* setup 'current-library-collection-paths' parameter */ + // setup 'current-library-collection-paths' parameter # if MZSCHEME_VERSION_MAJOR >= 299 { Scheme_Object *coll_path = NULL; @@ -1059,7 +1055,7 @@ startup_mzscheme(void) MZ_GC_DECL_REG(1); MZ_GC_VAR_IN_REG(0, coll_path); MZ_GC_REG(); - /* workaround for dynamic loading on windows */ + // workaround for dynamic loading on windows s = vim_getenv((char_u *)"PLTCOLLECTS", &mustfree); if (s != NULL) { @@ -1116,7 +1112,7 @@ startup_mzscheme(void) MZ_GC_DECL_REG(1); MZ_GC_VAR_IN_REG(0, config_path); MZ_GC_REG(); - /* workaround for dynamic loading on windows */ + // workaround for dynamic loading on windows s = vim_getenv((char_u *)"PLTCONFIGDIR", &mustfree); if (s != NULL) { @@ -1150,7 +1146,7 @@ startup_mzscheme(void) * we need to add them explicitly */ { - /* use error handler to avoid abort */ + // use error handler to avoid abort scheme_dynamic_wind(NULL, load_base_module, NULL, load_base_module_on_error, "racket/base"); if (load_base_module_failed) @@ -1164,10 +1160,10 @@ startup_mzscheme(void) } register_vim_exn(); - /* use new environment to initialise exception handling */ + // use new environment to initialise exception handling init_exn_catching_apply(); - /* redirect output */ + // redirect output scheme_console_output = do_output; scheme_console_printf = do_printf; @@ -1195,7 +1191,7 @@ startup_mzscheme(void) MZ_GC_CHECK(); #endif - /* setup sandbox guards */ + // setup sandbox guards if (make_security_guard != NULL) { Scheme_Object *args[3] = {NULL, NULL, NULL}; @@ -1223,7 +1219,7 @@ startup_mzscheme(void) MZ_GC_UNREG(); } #endif - /* Create buffer and window types for use in Scheme code */ + // Create buffer and window types for use in Scheme code mz_buffer_type = scheme_make_type("<vim-buffer>"); MZ_GC_CHECK(); mz_window_type = scheme_make_type("<vim-window>"); @@ -1278,7 +1274,7 @@ mzscheme_init(void) MZ_GC_REG(); config = scheme_current_config(); MZ_GC_CHECK(); - /* recreate ports each call effectively clearing these ones */ + // recreate ports each call effectively clearing these ones curout = scheme_make_byte_string_output_port(); MZ_GC_CHECK(); curerr = scheme_make_byte_string_output_port(); @@ -1323,24 +1319,24 @@ eval_with_exn_handling(void *data, Schem if (!value) { value = extract_exn_message(exn); - /* Got an exn? */ + // Got an exn? if (value) { - scheme_display(value, curerr); /* Send to stderr-vim */ + scheme_display(value, curerr); // Send to stderr-vim MZ_GC_CHECK(); do_flush(); } MZ_GC_UNREG(); - /* `raise' was called on some arbitrary value */ + // `raise' was called on some arbitrary value return FAIL; } - if (ret != NULL) /* if pointer to retval supported give it up */ + if (ret != NULL) // if pointer to retval supported give it up *ret = value; - /* Print any result, as long as it's not a void */ + // Print any result, as long as it's not a void else if (!SCHEME_VOIDP(value)) { - scheme_display(value, curout); /* Send to stdout-vim */ + scheme_display(value, curout); // Send to stdout-vim MZ_GC_CHECK(); } @@ -1349,7 +1345,9 @@ eval_with_exn_handling(void *data, Schem return OK; } -/* :mzscheme */ +/* + * :mzscheme + */ static int do_mzscheme_command(exarg_T *eap, void *data, Scheme_Closed_Prim *what) { @@ -1451,21 +1449,21 @@ do_load(void *data, int noargc UNUSED, S file = (char *)scheme_malloc_fail_ok(scheme_malloc_atomic, MAXPATHL + 1); MZ_GC_CHECK(); - /* make Vim expansion */ + // make Vim expansion expand_env((char_u *)pinfo->name, (char_u *)file, MAXPATHL); pinfo->port = scheme_open_input_file(file, "mzfile"); MZ_GC_CHECK(); - scheme_count_lines(pinfo->port); /* to get accurate read error location*/ + scheme_count_lines(pinfo->port); // to get accurate read error location MZ_GC_CHECK(); - /* Like REPL but print only last result */ + // Like REPL but print only last result while (!SCHEME_EOFP(expr = scheme_read(pinfo->port))) { result = scheme_eval(expr, environment); MZ_GC_CHECK(); } - /* errors will be caught in do_mzscheme_command and ex_mzfile */ + // errors will be caught in do_mzscheme_command and ex_mzfile scheme_close_input_port(pinfo->port); MZ_GC_CHECK(); pinfo->port = NULL; @@ -1473,7 +1471,9 @@ do_load(void *data, int noargc UNUSED, S return result; } -/* :mzfile */ +/* + * :mzfile + */ void ex_mzfile(exarg_T *eap) { @@ -1485,7 +1485,7 @@ ex_mzfile(exarg_T *eap) pinfo.name = (char *)eap->arg; if (do_mzscheme_command(eap, &pinfo, do_load) != OK - && pinfo.port != NULL) /* looks like port was not closed */ + && pinfo.port != NULL) // looks like port was not closed { scheme_close_input_port(pinfo.port); MZ_GC_CHECK(); @@ -1530,7 +1530,7 @@ init_exn_catching_apply(void) Scheme_Object *v; v = _scheme_apply(exn_catching_apply, 1, &f); - /* v is a pair: (cons #t value) or (cons #f exn) */ + // v is a pair: (cons #t value) or (cons #f exn) if (SCHEME_TRUEP(SCHEME_CAR(v))) return SCHEME_CDR(v); @@ -1547,7 +1547,7 @@ extract_exn_message(Scheme_Object *v) if (SCHEME_TRUEP(_scheme_apply(exn_p, 1, &v))) return _scheme_apply(exn_message, 1, &v); else - return NULL; /* Not an exn structure */ + return NULL; // Not an exn structure } static Scheme_Object * @@ -1588,7 +1588,7 @@ do_intrnl_output(char *mesg, int error) static void do_output(char *mesg, OUTPUT_LEN_TYPE len UNUSED) { - /* TODO: use len, the string may not be NUL terminated */ + // TODO: use len, the string may not be NUL terminated do_intrnl_output(mesg, 0); } @@ -1630,7 +1630,9 @@ do_flush(void) *======================================================================== */ -/* (command {command-string}) */ +/* + * (command {command-string}) + */ static Scheme_Object * vim_command(void *data, int argc, Scheme_Object **argv) { @@ -1641,7 +1643,7 @@ vim_command(void *data, int argc, Scheme MZ_GC_REG(); cmd = GUARANTEED_STRING_ARG(prim->name, 0); - /* may be use do_cmdline_cmd? */ + // may be use do_cmdline_cmd? do_cmdline(BYTE_STRING_VALUE(cmd), NULL, NULL, DOCMD_NOWAIT|DOCMD_VERBOSE); update_screen(VALID); @@ -1650,7 +1652,9 @@ vim_command(void *data, int argc, Scheme return scheme_void; } -/* (eval {expr-string}) */ +/* + * (eval {expr-string}) + */ static Scheme_Object * vim_eval(void *data UNUSED, int argc UNUSED, Scheme_Object **argv UNUSED) { @@ -1678,26 +1682,32 @@ vim_eval(void *data UNUSED, int argc UNU return result; #else raise_vim_exn(_("expressions disabled at compile time")); - /* unreachable */ + // unreachable return scheme_false; #endif } -/* (range-start) */ +/* + * (range-start) + */ static Scheme_Object * get_range_start(void *data UNUSED, int argc UNUSED, Scheme_Object **argv UNUSED) { return scheme_make_integer(range_start); } -/* (range-end) */ +/* + * (range-end) + */ static Scheme_Object * get_range_end(void *data UNUSED, int argc UNUSED, Scheme_Object **argv UNUSED) { return scheme_make_integer(range_end); } -/* (beep) */ +/* + * (beep) + */ static Scheme_Object * mzscheme_beep(void *data UNUSED, int argc UNUSED, Scheme_Object **argv UNUSED) { @@ -1707,7 +1717,9 @@ mzscheme_beep(void *data UNUSED, int arg static Scheme_Object *M_global = NULL; -/* (get-option {option-name}) [buffer/window] */ +/* + * (get-option {option-name}) [buffer/window] + */ static Scheme_Object * get_option(void *data, int argc, Scheme_Object **argv) { @@ -1775,17 +1787,19 @@ get_option(void *data, int argc, Scheme_ case -2: MZ_GC_UNREG(); raise_vim_exn(_("hidden option")); - /*NOTREACHED*/ + //NOTREACHED case -3: MZ_GC_UNREG(); raise_vim_exn(_("unknown option")); - /*NOTREACHED*/ + //NOTREACHED } - /* unreachable */ + // unreachable return scheme_void; } -/* (set-option {option-changing-string} [buffer/window]) */ +/* + * (set-option {option-changing-string} [buffer/window]) + */ static Scheme_Object * set_option(void *data, int argc, Scheme_Object **argv) { @@ -1828,7 +1842,7 @@ set_option(void *data, int argc, Scheme_ scheme_wrong_type(prim->name, "vim-buffer/window", 1, argc, argv); } - /* do_set can modify cmd, make copy */ + // do_set can modify cmd, make copy command = vim_strsave(BYTE_STRING_VALUE(cmd)); MZ_GC_UNREG(); do_set(command, opt_flags); @@ -1846,14 +1860,18 @@ set_option(void *data, int argc, Scheme_ *=========================================================================== */ -/* (curr-win) */ +/* + * (curr-win) + */ static Scheme_Object * get_curr_win(void *data UNUSED, int argc UNUSED, Scheme_Object **argv UNUSED) { return (Scheme_Object *)get_vim_curr_window(); } -/* (win-count) */ +/* + * (win-count) + */ static Scheme_Object * get_window_count(void *data UNUSED, int argc UNUSED, Scheme_Object **argv UNUSED) { @@ -1865,7 +1883,9 @@ get_window_count(void *data UNUSED, int return scheme_make_integer(n); } -/* (get-win-list [buffer]) */ +/* + * (get-win-list [buffer]) + */ static Scheme_Object * get_window_list(void *data, int argc, Scheme_Object **argv) { @@ -1895,14 +1915,13 @@ window_new(win_T *win) MZ_GC_DECL_REG(1); MZ_GC_VAR_IN_REG(0, self); - /* We need to handle deletion of windows underneath us. - * If we add a "w_mzscheme_ref" field to the win_T structure, - * then we can get at it in win_free() in vim. - * - * On a win_free() we set the Scheme object's win_T *field - * to an invalid value. We trap all uses of a window - * object, and reject them if the win_T *field is invalid. - */ + // We need to handle deletion of windows underneath us. + // If we add a "w_mzscheme_ref" field to the win_T structure, + // then we can get at it in win_free() in vim. + // + // On a win_free() we set the Scheme object's win_T *field + // to an invalid value. We trap all uses of a window + // object, and reject them if the win_T *field is invalid. if (win->w_mzscheme_ref != NULL) return (Scheme_Object *)WINDOW_REF(win); @@ -1910,7 +1929,7 @@ window_new(win_T *win) self = scheme_malloc_fail_ok(scheme_malloc_tagged, sizeof(vim_mz_window)); vim_memset(self, 0, sizeof(vim_mz_window)); #ifndef MZ_PRECISE_GC - scheme_dont_gc_ptr(self); /* because win isn't visible to GC */ + scheme_dont_gc_ptr(self); // because win isn't visible to GC #else win->w_mzscheme_ref = scheme_malloc_immobile_box(NULL); #endif @@ -1924,7 +1943,9 @@ window_new(win_T *win) return (Scheme_Object *)self; } -/* (get-win-num [window]) */ +/* + * (get-win-num [window]) + */ static Scheme_Object * get_window_num(void *data UNUSED, int argc UNUSED, Scheme_Object **argv UNUSED) { @@ -1939,7 +1960,9 @@ get_window_num(void *data UNUSED, int ar return scheme_make_integer(nr); } -/* (get-win-by-num {windownum}) */ +/* + * (get-win-by-num {windownum}) + */ static Scheme_Object * get_window_by_num(void *data, int argc, Scheme_Object **argv) { @@ -1952,13 +1975,15 @@ get_window_by_num(void *data, int argc, scheme_signal_error(_("window index is out of range")); for ( ; win != NULL; win = win->w_next, --fnum) - if (fnum == 1) /* to be 1-based */ + if (fnum == 1) // to be 1-based return window_new(win); return scheme_false; } -/* (get-win-buffer [window]) */ +/* + * (get-win-buffer [window]) + */ static Scheme_Object * get_window_buffer(void *data, int argc, Scheme_Object **argv) { @@ -1968,7 +1993,9 @@ get_window_buffer(void *data, int argc, return buffer_new(win->win->w_buffer); } -/* (get-win-height [window]) */ +/* + * (get-win-height [window]) + */ static Scheme_Object * get_window_height(void *data, int argc, Scheme_Object **argv) { @@ -1978,7 +2005,9 @@ get_window_height(void *data, int argc, return scheme_make_integer(win->win->w_height); } -/* (set-win-height {height} [window]) */ +/* + * (set-win-height {height} [window]) + */ static Scheme_Object * set_window_height(void *data, int argc, Scheme_Object **argv) { @@ -2003,7 +2032,9 @@ set_window_height(void *data, int argc, return scheme_void; } -/* (get-win-width [window]) */ +/* + * (get-win-width [window]) + */ static Scheme_Object * get_window_width(void *data, int argc, Scheme_Object **argv) { @@ -2013,7 +2044,9 @@ get_window_width(void *data, int argc, S return scheme_make_integer(win->win->w_width); } -/* (set-win-width {width} [window]) */ +/* + * (set-win-width {width} [window]) + */ static Scheme_Object * set_window_width(void *data, int argc, Scheme_Object **argv) { @@ -2038,7 +2071,9 @@ set_window_width(void *data, int argc, S return scheme_void; } -/* (get-cursor [window]) -> (line . col) */ +/* + * (get-cursor [window]) -> (line . col) + */ static Scheme_Object * get_cursor(void *data, int argc, Scheme_Object **argv) { @@ -2052,7 +2087,9 @@ get_cursor(void *data, int argc, Scheme_ scheme_make_integer_value((long)pos.col + 1)); } -/* (set-cursor (line . col) [window]) */ +/* + * (set-cursor (line . col) [window]) + */ static Scheme_Object * set_cursor(void *data, int argc, Scheme_Object **argv) { @@ -2075,7 +2112,7 @@ set_cursor(void *data, int argc, Scheme_ col = SCHEME_INT_VAL(SCHEME_CDR(argv[0])) - 1; check_line_range(lnum, win->win->w_buffer); - /* don't know how to catch invalid column value */ + // don't know how to catch invalid column value win->win->w_cursor.lnum = lnum; win->win->w_cursor.col = col; @@ -2091,7 +2128,9 @@ set_cursor(void *data, int argc, Scheme_ *=========================================================================== */ -/* (open-buff {filename}) */ +/* + * (open-buff {filename}) + */ static Scheme_Object * mzscheme_open_buffer(void *data, int argc, Scheme_Object **argv) { @@ -2111,7 +2150,7 @@ mzscheme_open_buffer(void *data, int arg #ifdef HAVE_SANDBOX sandbox_check(); #endif - /* TODO make open existing file */ + // TODO make open existing file num = buflist_add(BYTE_STRING_VALUE(fname), BLN_LISTED | BLN_CURBUF); if (num == 0) @@ -2123,7 +2162,9 @@ mzscheme_open_buffer(void *data, int arg return buf; } -/* (get-buff-by-num {buffernum}) */ +/* + * (get-buff-by-num {buffernum}) + */ static Scheme_Object * get_buffer_by_num(void *data, int argc, Scheme_Object **argv) { @@ -2140,7 +2181,9 @@ get_buffer_by_num(void *data, int argc, return scheme_false; } -/* (get-buff-by-name {buffername}) */ +/* + * (get-buff-by-name {buffername}) + */ static Scheme_Object * get_buffer_by_name(void *data, int argc, Scheme_Object **argv) { @@ -2159,7 +2202,7 @@ get_buffer_by_name(void *data, int argc, FOR_ALL_BUFFERS(buf) { if (buf->b_ffname == NULL || buf->b_sfname == NULL) - /* empty string */ + // empty string { if (BYTE_STRING_VALUE(fname)[0] == NUL) buffer = buffer_new(buf); @@ -2167,7 +2210,7 @@ get_buffer_by_name(void *data, int argc, else if (!fnamecmp(buf->b_ffname, BYTE_STRING_VALUE(fname)) || !fnamecmp(buf->b_sfname, BYTE_STRING_VALUE(fname))) { - /* either short or long filename matches */ + // either short or long filename matches buffer = buffer_new(buf); } } @@ -2176,7 +2219,9 @@ get_buffer_by_name(void *data, int argc, return buffer; } -/* (get-next-buff [buffer]) */ +/* + * (get-next-buff [buffer]) + */ static Scheme_Object * get_next_buffer(void *data, int argc, Scheme_Object **argv) { @@ -2189,7 +2234,9 @@ get_next_buffer(void *data, int argc, Sc return buffer_new(buf->b_next); } -/* (get-prev-buff [buffer]) */ +/* + * (get-prev-buff [buffer]) + */ static Scheme_Object * get_prev_buffer(void *data, int argc, Scheme_Object **argv) { @@ -2202,7 +2249,9 @@ get_prev_buffer(void *data, int argc, Sc return buffer_new(buf->b_prev); } -/* (get-buff-num [buffer]) */ +/* + * (get-buff-num [buffer]) + */ static Scheme_Object * get_buffer_num(void *data, int argc, Scheme_Object **argv) { @@ -2212,7 +2261,9 @@ get_buffer_num(void *data, int argc, Sch return scheme_make_integer(buf->buf->b_fnum); } -/* (buff-count) */ +/* + * (buff-count) + */ static Scheme_Object * get_buffer_count(void *data UNUSED, int argc UNUSED, Scheme_Object **argv UNUSED) { @@ -2223,7 +2274,9 @@ get_buffer_count(void *data UNUSED, int return scheme_make_integer(n); } -/* (get-buff-name [buffer]) */ +/* + * (get-buff-name [buffer]) + */ static Scheme_Object * get_buffer_name(void *data, int argc, Scheme_Object **argv) { @@ -2233,7 +2286,9 @@ get_buffer_name(void *data, int argc, Sc return scheme_make_byte_string((char *)buf->buf->b_ffname); } -/* (curr-buff) */ +/* + * (curr-buff) + */ static Scheme_Object * get_curr_buffer(void *data UNUSED, int argc UNUSED, Scheme_Object **argv UNUSED) { @@ -2248,10 +2303,9 @@ buffer_new(buf_T *buf) MZ_GC_DECL_REG(1); MZ_GC_VAR_IN_REG(0, self); - /* We need to handle deletion of buffers underneath us. - * If we add a "b_mzscheme_ref" field to the buf_T structure, - * then we can get at it in buf_freeall() in vim. - */ + // We need to handle deletion of buffers underneath us. + // If we add a "b_mzscheme_ref" field to the buf_T structure, + // then we can get at it in buf_freeall() in vim. if (buf->b_mzscheme_ref) return (Scheme_Object *)BUFFER_REF(buf); @@ -2259,7 +2313,7 @@ buffer_new(buf_T *buf) self = scheme_malloc_fail_ok(scheme_malloc_tagged, sizeof(vim_mz_buffer)); vim_memset(self, 0, sizeof(vim_mz_buffer)); #ifndef MZ_PRECISE_GC - scheme_dont_gc_ptr(self); /* because buf isn't visible to GC */ + scheme_dont_gc_ptr(self); // because buf isn't visible to GC #else buf->b_mzscheme_ref = scheme_malloc_immobile_box(NULL); #endif @@ -2354,7 +2408,7 @@ get_buffer_line_list(void *data, int arg (char *)ml_get_buf(buf->buf, (linenr_T)(lo+i), FALSE)); raise_if_error(); - /* Set the list item */ + // Set the list item list = scheme_make_pair(str, list); MZ_GC_CHECK(); } @@ -2377,12 +2431,11 @@ get_buffer_line_list(void *data, int arg static Scheme_Object * set_buffer_line(void *data, int argc, Scheme_Object **argv) { - /* First of all, we check the value of the supplied MzScheme object. - * There are three cases: - * 1. #f - this is a deletion. - * 2. A string - this is a replacement. - * 3. Anything else - this is an error. - */ + // First of all, we check the value of the supplied MzScheme object. + // There are three cases: + // 1. #f - this is a deletion. + // 2. A string - this is a replacement. + // 3. Anything else - this is an error. Vim_Prim *prim = (Vim_Prim *)data; vim_mz_buffer *buf; Scheme_Object *line = NULL; @@ -2432,7 +2485,7 @@ set_buffer_line(void *data, int argc, Sc } else { - /* Otherwise it's a line */ + // Otherwise it's a line buf_T *savebuf = curbuf; save = string_to_line(line); @@ -2459,7 +2512,7 @@ set_buffer_line(void *data, int argc, Sc curbuf = savebuf; - /* Check that the cursor is not beyond the end of the line now. */ + // Check that the cursor is not beyond the end of the line now. if (buf->buf == curwin->w_buffer) check_cursor_col(); @@ -2493,12 +2546,11 @@ free_array(char **array) static Scheme_Object * set_buffer_line_list(void *data, int argc, Scheme_Object **argv) { - /* First of all, we check the type of the supplied MzScheme object. - * There are three cases: - * 1. #f - this is a deletion. - * 2. A list - this is a replacement. - * 3. Anything else - this is an error. - */ + // First of all, we check the type of the supplied MzScheme object. + // There are three cases: + // 1. #f - this is a deletion. + // 2. A list - this is a replacement. + // 3. Anything else - this is an error. Vim_Prim *prim = (Vim_Prim *)data; vim_mz_buffer *buf = NULL; Scheme_Object *line_list = NULL; @@ -2520,7 +2572,7 @@ set_buffer_line_list(void *data, int arg line_list = argv[2]; buf = get_buffer_arg(prim->name, 3, argc, argv); old_len = hi - lo; - if (old_len < 0) /* process inverse values wisely */ + if (old_len < 0) // process inverse values wisely { i = lo; lo = hi; @@ -2529,8 +2581,8 @@ set_buffer_line_list(void *data, int arg } extra = 0; - check_line_range(lo, buf->buf); /* inclusive */ - check_line_range(hi - 1, buf->buf); /* exclusive */ + check_line_range(lo, buf->buf); // inclusive + check_line_range(hi - 1, buf->buf); // exclusive if (SCHEME_FALSEP(line_list) || SCHEME_NULLP(line_list)) { @@ -2565,10 +2617,10 @@ set_buffer_line_list(void *data, int arg { buf_T *savebuf = curbuf; - /* List */ + // List new_len = scheme_proper_list_length(line_list); MZ_GC_CHECK(); - if (new_len < 0) /* improper or cyclic list */ + if (new_len < 0) // improper or cyclic list scheme_wrong_type(prim->name, "proper list", 2, argc, argv); else @@ -2713,7 +2765,7 @@ insert_buffer_line_list(void *data, int scheme_wrong_type(prim->name, "string or list", 1, argc, argv); buf = get_buffer_arg(prim->name, 2, argc, argv); - if (n != 0) /* 0 can be used in insert */ + if (n != 0) // 0 can be used in insert check_line_range(n, buf->buf); if (SCHEME_STRINGP(list)) { @@ -2748,10 +2800,10 @@ insert_buffer_line_list(void *data, int return scheme_void; } - /* List */ + // List size = scheme_proper_list_length(list); MZ_GC_CHECK(); - if (size < 0) /* improper or cyclic list */ + if (size < 0) // improper or cyclic list scheme_wrong_type(prim->name, "proper list", 2, argc, argv); else @@ -2813,7 +2865,9 @@ insert_buffer_line_list(void *data, int /* * Predicates */ -/* (buff? obj) */ +/* + * (buff? obj) + */ static Scheme_Object * vim_bufferp(void *data UNUSED, int argc UNUSED, Scheme_Object **argv) { @@ -2823,7 +2877,9 @@ vim_bufferp(void *data UNUSED, int argc return scheme_false; } -/* (win? obj) */ +/* + * (win? obj) + */ static Scheme_Object * vim_windowp(void *data UNUSED, int argc UNUSED, Scheme_Object **argv) { @@ -2833,7 +2889,9 @@ vim_windowp(void *data UNUSED, int argc return scheme_false; } -/* (buff-valid? obj) */ +/* + * (buff-valid? obj) + */ static Scheme_Object * vim_buffer_validp(void *data UNUSED, int argc UNUSED, Scheme_Object **argv) { @@ -2844,7 +2902,9 @@ vim_buffer_validp(void *data UNUSED, int return scheme_false; } -/* (win-valid? obj) */ +/* + * (win-valid? obj) + */ static Scheme_Object * vim_window_validp(void *data UNUSED, int argc UNUSED, Scheme_Object **argv) { @@ -2879,18 +2939,16 @@ string_to_line(Scheme_Object *obj) scheme_str = scheme_display_to_string(obj, &len); - /* Error checking: String must not contain newlines, as we - * are replacing a single line, and we must replace it with - * a single line. - */ + // Error checking: String must not contain newlines, as we + // are replacing a single line, and we must replace it with + // a single line. if (memchr(scheme_str, '\n', len)) scheme_signal_error(_("string cannot contain newlines")); vim_str = alloc(len + 1); - /* Create a copy of the string, with internal nulls replaced by - * newline characters, as is the vim convention. - */ + // Create a copy of the string, with internal nulls replaced by + // newline characters, as is the vim convention. for (i = 0; i < len; ++i) { if (scheme_str[i] == '\0') @@ -2913,7 +2971,7 @@ string_to_line(Scheme_Object *obj) vim_to_mzscheme(typval_T *vim_value) { Scheme_Object *result = NULL; - /* hash table to store visited values to avoid infinite loops */ + // hash table to store visited values to avoid infinite loops Scheme_Hash_Table *visited = NULL; MZ_GC_DECL_REG(2); @@ -2941,19 +2999,18 @@ vim_to_mzscheme_impl(typval_T *vim_value MZ_GC_VAR_IN_REG(1, visited); MZ_GC_REG(); - /* Avoid infinite recursion */ + // Avoid infinite recursion if (depth > 100) { MZ_GC_UNREG(); return scheme_void; } - /* Check if we run into a recursive loop. The item must be in visited - * then and we can use it again. - */ + // Check if we run into a recursive loop. The item must be in visited + // then and we can use it again. result = scheme_hash_get(visited, (Scheme_Object *)vim_value); MZ_GC_CHECK(); - if (result != NULL) /* found, do nothing */ + if (result != NULL) // found, do nothing new_value = FALSE; else if (vim_value->v_type == VAR_STRING) { @@ -3046,7 +3103,7 @@ vim_to_mzscheme_impl(typval_T *vim_value MZ_GC_VAR_IN_REG(0, funcname); MZ_GC_REG(); - /* FIXME: func_ref() and func_unref() are needed. */ + // FIXME: func_ref() and func_unref() are needed. funcname = scheme_make_byte_string((char *)vim_value->vval.v_string); MZ_GC_CHECK(); result = scheme_make_closed_prim_w_arity(vim_funcref, funcname, @@ -3067,8 +3124,8 @@ vim_to_mzscheme_impl(typval_T *vim_value MZ_GC_VAR_IN_REG(0, funcname); MZ_GC_REG(); - /* FIXME: func_ref() and func_unref() are needed. */ - /* TODO: Support pt_dict and pt_argv. */ + // FIXME: func_ref() and func_unref() are needed. + // TODO: Support pt_dict and pt_argv. funcname = scheme_make_byte_string( (char *)partial_name(vim_value->vval.v_partial)); MZ_GC_CHECK(); @@ -3118,7 +3175,7 @@ mzscheme_to_vim(Scheme_Object *obj, typv status = mzscheme_to_vim_impl(obj, tv, 1, visited); for (i = 0; i < visited->size; ++i) { - /* free up remembered objects */ + // free up remembered objects if (visited->vals[i] != NULL) free_tv((typval_T *)visited->vals[i]); } @@ -3139,7 +3196,7 @@ mzscheme_to_vim_impl(Scheme_Object *obj, MZ_GC_REG(); MZ_GC_CHECK(); - if (depth > 100) /* limit the deepest recursion level */ + if (depth > 100) // limit the deepest recursion level { tv->v_type = VAR_NUMBER; tv->vval.v_number = 0; @@ -3201,7 +3258,7 @@ mzscheme_to_vim_impl(Scheme_Object *obj, int i; Scheme_Object *curr = NULL; Scheme_Object *cval = NULL; - /* temporary var to hold current element of vectors and pairs */ + // temporary var to hold current element of vectors and pairs typval_T *v; MZ_GC_DECL_REG(2); @@ -3218,8 +3275,8 @@ mzscheme_to_vim_impl(Scheme_Object *obj, status = FAIL; else { - /* add the value in advance to allow handling of self-referential - * data structures */ + // add the value in advance to allow handling of self-referential + // data structures typval_T *visited_tv = ALLOC_ONE(typval_T); copy_tv(tv, visited_tv); scheme_hash_set(visited, obj, (Scheme_Object *)visited_tv); @@ -3253,8 +3310,8 @@ mzscheme_to_vim_impl(Scheme_Object *obj, if (status == FAIL) break; } - /* improper list not terminated with null - * need to handle the last element */ + // improper list not terminated with null + // need to handle the last element if (status == OK && !SCHEME_NULLP(curr)) { status = mzscheme_to_vim_impl(cval, v, depth + 1, visited); @@ -3265,7 +3322,7 @@ mzscheme_to_vim_impl(Scheme_Object *obj, } } } - /* nothing to do for scheme_null */ + // nothing to do for scheme_null vim_free(v); } MZ_GC_UNREG(); @@ -3301,10 +3358,10 @@ mzscheme_to_vim_impl(Scheme_Object *obj, { if (((Scheme_Hash_Table *) obj)->vals[i] != NULL) { - /* generate item for `display'ed Scheme key */ + // generate item for `display'ed Scheme key dictitem_T *item = dictitem_alloc((char_u *)string_to_line( ((Scheme_Hash_Table *) obj)->keys[i])); - /* convert Scheme val to Vim and add it to the dict */ + // convert Scheme val to Vim and add it to the dict if (mzscheme_to_vim_impl(((Scheme_Hash_Table *) obj)->vals[i], &item->di_tv, depth + 1, visited) == FAIL || dict_add(dict, item) == FAIL) @@ -3321,7 +3378,7 @@ mzscheme_to_vim_impl(Scheme_Object *obj, } else { - /* `display' any other value to string */ + // `display' any other value to string tv->v_type = VAR_STRING; tv->vval.v_string = (char_u *)string_to_line(obj); } @@ -3329,7 +3386,9 @@ mzscheme_to_vim_impl(Scheme_Object *obj, return status; } -/* Scheme prim procedure wrapping Vim funcref */ +/* + * Scheme prim procedure wrapping Vim funcref + */ static Scheme_Object * vim_funcref(void *name, int argc, Scheme_Object **argv) { @@ -3546,7 +3605,8 @@ raise_if_error(void) raise_vim_exn(NULL); } -/* get buffer: +/* + * get buffer: * either current * or passed as argv[argnum] with checks */ @@ -3564,7 +3624,8 @@ get_buffer_arg(const char *fname, int ar return b; } -/* get window: +/* + * get window: * either current * or passed as argv[argnum] with checks */ @@ -3582,7 +3643,9 @@ get_window_arg(const char *fname, int ar return w; } -/* get valid Vim buffer from Scheme_Object* */ +/* + * get valid Vim buffer from Scheme_Object* + */ buf_T *get_valid_buffer(void *obj) { buf_T *buf = ((vim_mz_buffer *)obj)->buf; @@ -3592,7 +3655,9 @@ buf_T *get_valid_buffer(void *obj) return buf; } -/* get valid Vim window from Scheme_Object* */ +/* + * get valid Vim window from Scheme_Object* + */ win_T *get_valid_window(void *obj) { win_T *win = ((vim_mz_window *)obj)->win; @@ -3631,8 +3696,8 @@ mz_fix_cursor(int lo, int hi, int extra) { if (curwin->w_cursor.lnum >= lo) { - /* Adjust the cursor position if it's in/after the changed - * lines. */ + // Adjust the cursor position if it's in/after the changed + // lines. if (curwin->w_cursor.lnum >= hi) { curwin->w_cursor.lnum += extra; @@ -3704,7 +3769,9 @@ static Vim_Prim prims[]= {vim_window_validp, "win-valid?", 1, 1} }; -/* return MzScheme wrapper for curbuf */ +/* + * return MzScheme wrapper for curbuf + */ static vim_mz_buffer * get_vim_curr_buffer(void) { @@ -3714,7 +3781,9 @@ get_vim_curr_buffer(void) return BUFFER_REF(curbuf); } -/* return MzScheme wrapper for curwin */ +/* + * return MzScheme wrapper for curwin + */ static vim_mz_window * get_vim_curr_window(void) { @@ -3742,7 +3811,7 @@ make_modules(void) MZ_GC_CHECK(); mod = scheme_primitive_module(vimext_symbol, environment); MZ_GC_CHECK(); - /* all prims made closed so they can access their own names */ + // all prims made closed so they can access their own names for (i = 0; i < (int)(sizeof(prims)/sizeof(prims[0])); i++) { Vim_Prim *prim = prims + i; @@ -3769,7 +3838,9 @@ sandbox_check(void) raise_vim_exn(_("not allowed in the Vim sandbox")); } -/* security guards to force Vim's sandbox restrictions on MzScheme level */ +/* + * security guards to force Vim's sandbox restrictions on MzScheme level + */ static Scheme_Object * sandbox_file_guard(int argc UNUSED, Scheme_Object **argv) {
--- a/src/if_perlsfio.c +++ b/src/if_perlsfio.c @@ -10,14 +10,14 @@ * if_perlsfio.c: Special I/O functions for Perl interface. */ -#define _memory_h /* avoid memset redeclaration */ -#define IN_PERL_FILE /* don't include if_perl.pro from prot.h */ +#define _memory_h // avoid memset redeclaration +#define IN_PERL_FILE // don't include if_perl.pro from prot.h #include "vim.h" #if defined(USE_SFIO) || defined(PROTO) -#ifndef USE_SFIO /* just generating prototypes */ +#ifndef USE_SFIO // just generating prototypes # define Sfio_t int # define Sfdisc_t int #endif @@ -26,10 +26,10 @@ static int sfvimwrite( - Sfio_t *f, /* stream involved */ - char *buf, /* buffer to read from */ - int n, /* number of bytes to write */ - Sfdisc_t *disc) /* discipline */ + Sfio_t *f, // stream involved + char *buf, // buffer to read from + int n, // number of bytes to write + Sfdisc_t *disc) // discipline { char_u *str; @@ -63,4 +63,4 @@ sfdcnewvim(void) return disc; } -#endif /* USE_SFIO */ +#endif // USE_SFIO
--- a/src/if_python.c +++ b/src/if_python.c @@ -21,16 +21,15 @@ #include <limits.h> -/* uncomment this if used with the debug version of python. - * Checked on 2.7.4. */ -/* #define Py_DEBUG */ -/* Note: most of time you can add -DPy_DEBUG to CFLAGS in place of uncommenting - */ -/* uncomment this if used with the debug version of python, but without its - * allocator */ -/* #define Py_DEBUG_NO_PYMALLOC */ +// uncomment this if used with the debug version of python. +// Checked on 2.7.4. +// #define Py_DEBUG +// Note: most of time you can add -DPy_DEBUG to CFLAGS in place of uncommenting +// uncomment this if used with the debug version of python, but without its +// allocator +// #define Py_DEBUG_NO_PYMALLOC -/* Python.h defines _POSIX_THREADS itself (if needed) */ +// Python.h defines _POSIX_THREADS itself (if needed) #ifdef _POSIX_THREADS # undef _POSIX_THREADS #endif @@ -53,13 +52,13 @@ # undef HAVE_PUTENV #endif #ifdef HAVE_STDARG_H -# undef HAVE_STDARG_H /* Python's config.h defines it as well. */ +# undef HAVE_STDARG_H // Python's config.h defines it as well. #endif #ifdef _POSIX_C_SOURCE -# undef _POSIX_C_SOURCE /* pyconfig.h defines it as well. */ +# undef _POSIX_C_SOURCE // pyconfig.h defines it as well. #endif #ifdef _XOPEN_SOURCE -# undef _XOPEN_SOURCE /* pyconfig.h defines it as well. */ +# undef _XOPEN_SOURCE // pyconfig.h defines it as well. #endif #define PY_SSIZE_T_CLEAN @@ -70,8 +69,8 @@ # undef PY_SSIZE_T_CLEAN #endif -#undef main /* Defined in python.h - aargh */ -#undef HAVE_FCNTL_H /* Clash with os_win32.h */ +#undef main // Defined in python.h - aargh +#undef HAVE_FCNTL_H // Clash with os_win32.h // Perhaps leave this out for Python 2.6, which supports bytes? #define PyBytes_FromString PyString_FromString @@ -80,7 +79,7 @@ #define PyBytes_FromStringAndSize PyString_FromStringAndSize #if !defined(FEAT_PYTHON) && defined(PROTO) -/* Use this to be able to generate prototypes without python being used. */ +// Use this to be able to generate prototypes without python being used. # define PyObject Py_ssize_t # define PyThreadState Py_ssize_t # define PyTypeObject Py_ssize_t @@ -112,19 +111,19 @@ struct PyMethodDef { Py_ssize_t a; }; #endif #define Py_bytes_fmt "s" -/* Parser flags */ +// Parser flags #define single_input 256 #define file_input 257 #define eval_input 258 #if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x020300F0 - /* Python 2.3: can invoke ":python" recursively. */ + // Python 2.3: can invoke ":python" recursively. # define PY_CAN_RECURSE #endif #if defined(DYNAMIC_PYTHON) || defined(PROTO) # ifndef DYNAMIC_PYTHON -# define HINSTANCE long_u /* for generating prototypes */ +# define HINSTANCE long_u // for generating prototypes # endif # ifndef MSWIN @@ -144,8 +143,8 @@ struct PyMethodDef { Py_ssize_t a; }; # define symbol_from_dll GetProcAddress # endif -/* This makes if_python.c compile without warnings against Python 2.5 - * on Win32 and Win64. */ +// This makes if_python.c compile without warnings against Python 2.5 +// on Win32 and Win64. # undef PyRun_SimpleString # undef PyRun_String # undef PyArg_Parse @@ -456,9 +455,9 @@ static void* (*dll_PyCObject_AsVoidPtr)( static int* dll_Py_NoSiteFlag; # endif -static HINSTANCE hinstPython = 0; /* Instance of python.dll */ +static HINSTANCE hinstPython = 0; // Instance of python.dll -/* Imported exception objects */ +// Imported exception objects static PyObject *imp_PyExc_AttributeError; static PyObject *imp_PyExc_IndexError; static PyObject *imp_PyExc_KeyError; @@ -681,9 +680,9 @@ python_runtime_link_init(char *libname, (PYTHON_PROC*)&py_PyUnicode_AsEncodedString; # if !(defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)) && defined(UNIX) && defined(FEAT_PYTHON3) - /* Can't have Python and Python3 loaded at the same time. - * It cause a crash, because RTLD_GLOBAL is needed for - * standard C extension libraries of one or both python versions. */ + // Can't have Python and Python3 loaded at the same time. + // It cause a crash, because RTLD_GLOBAL is needed for + // standard C extension libraries of one or both python versions. if (python3_loaded()) { if (verbose) @@ -715,8 +714,8 @@ python_runtime_link_init(char *libname, } } - /* Load unicode functions separately as only the ucs2 or the ucs4 functions - * will be present in the library. */ + // Load unicode functions separately as only the ucs2 or the ucs4 functions + // will be present in the library. *ucs_as_encoded_string = symbol_from_dll(hinstPython, "PyUnicodeUCS2_AsEncodedString"); if (*ucs_as_encoded_string == NULL) @@ -775,7 +774,7 @@ get_exceptions(void) Py_XINCREF(imp_PyExc_OverflowError); Py_XDECREF(exmod); } -#endif /* DYNAMIC_PYTHON */ +#endif // DYNAMIC_PYTHON static int initialised = 0; #define PYINITIALISED initialised @@ -830,18 +829,16 @@ typedef PySliceObject PySliceObject_T; #include "if_py_both.h" -/****************************************************** - * Internal function prototypes. - */ +/////////////////////////////////////////////////////// +// Internal function prototypes. static int PythonMod_Init(void); -/****************************************************** - * 1. Python interpreter main program. - */ +/////////////////////////////////////////////////////// +// 1. Python interpreter main program. -#if PYTHON_API_VERSION < 1007 /* Python 1.4 */ +#if PYTHON_API_VERSION < 1007 // Python 1.4 typedef PyObject PyThreadState; #endif @@ -875,7 +872,7 @@ python_end(void) { static int recurse = 0; - /* If a crash occurs while doing this, don't try again. */ + // If a crash occurs while doing this, don't try again. if (recurse != 0) return; @@ -888,7 +885,7 @@ python_end(void) # ifdef PY_CAN_RECURSE PyGILState_Ensure(); # else - Python_RestoreThread(); /* enter python */ + Python_RestoreThread(); // enter python # endif Py_Finalize(); } @@ -899,7 +896,7 @@ python_end(void) # ifdef PY_CAN_RECURSE PyGILState_Ensure(); # else - Python_RestoreThread(); /* enter python */ + Python_RestoreThread(); // enter python # endif Py_Finalize(); } @@ -937,7 +934,7 @@ Python_Init(void) if (*p_pyhome != NUL) { - /* The string must not change later, make a copy in static memory. */ + // The string must not change later, make a copy in static memory. py_home_buf = (char *)vim_strsave(p_pyhome); if (py_home_buf != NULL) Py_SetPythonHome(py_home_buf); @@ -950,15 +947,15 @@ Python_Init(void) init_structs(); #if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000 - /* Disable implicit 'import site', because it may cause Vim to exit - * when it can't be found. */ + // Disable implicit 'import site', because it may cause Vim to exit + // when it can't be found. Py_NoSiteFlag++; #endif Py_Initialize(); #if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000 - /* 'import site' explicitly. */ + // 'import site' explicitly. site = PyImport_ImportModule("site"); if (site == NULL) { @@ -968,10 +965,10 @@ Python_Init(void) Py_DECREF(site); #endif - /* Initialise threads, and below save the state using - * PyEval_SaveThread. Without the call to PyEval_SaveThread, thread - * specific state (such as the system trace hook), will be lost - * between invocations of Python code. */ + // Initialise threads, and below save the state using + // PyEval_SaveThread. Without the call to PyEval_SaveThread, thread + // specific state (such as the system trace hook), will be lost + // between invocations of Python code. PyEval_InitThreads(); #ifdef DYNAMIC_PYTHON get_exceptions(); @@ -985,19 +982,18 @@ Python_Init(void) globals = PyModule_GetDict(PyImport_AddModule("__main__")); - /* Remove the element from sys.path that was added because of our - * argv[0] value in PythonMod_Init(). Previously we used an empty - * string, but depending on the OS we then get an empty entry or - * the current directory in sys.path. */ + // Remove the element from sys.path that was added because of our + // argv[0] value in PythonMod_Init(). Previously we used an empty + // string, but depending on the OS we then get an empty entry or + // the current directory in sys.path. PyRun_SimpleString("import sys; sys.path = filter(lambda x: x != '/must>not&exist', sys.path)"); - /* lock is created and acquired in PyEval_InitThreads() and thread - * state is created in Py_Initialize() - * there _PyGILState_NoteThreadState() also sets gilcounter to 1 - * (python must have threads enabled!) - * so the following does both: unlock GIL and save thread state in TLS - * without deleting thread state - */ + // lock is created and acquired in PyEval_InitThreads() and thread + // state is created in Py_Initialize() + // there _PyGILState_NoteThreadState() also sets gilcounter to 1 + // (python must have threads enabled!) + // so the following does both: unlock GIL and save thread state in TLS + // without deleting thread state #ifndef PY_CAN_RECURSE saved_python_thread = #endif @@ -1009,11 +1005,10 @@ Python_Init(void) return 0; fail: - /* We call PythonIO_Flush() here to print any Python errors. - * This is OK, as it is possible to call this function even - * if PythonIO_Init_io() has not completed successfully (it will - * not do anything in this case). - */ + // We call PythonIO_Flush() here to print any Python errors. + // This is OK, as it is possible to call this function even + // if PythonIO_Init_io() has not completed successfully (it will + // not do anything in this case). PythonIO_Flush(); return -1; } @@ -1050,16 +1045,16 @@ DoPyCommand(const char *cmd, rangeinitia init_range(arg); - Python_Release_Vim(); /* leave vim */ + Python_Release_Vim(); // leave Vim #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) - /* Python only works properly when the LC_NUMERIC locale is "C". */ + // Python only works properly when the LC_NUMERIC locale is "C". saved_locale = setlocale(LC_NUMERIC, NULL); if (saved_locale == NULL || STRCMP(saved_locale, "C") == 0) saved_locale = NULL; else { - /* Need to make a copy, value may change when setting new locale. */ + // Need to make a copy, value may change when setting new locale. saved_locale = (char *) PY_STRSAVE(saved_locale); (void)setlocale(LC_NUMERIC, "C"); } @@ -1068,7 +1063,7 @@ DoPyCommand(const char *cmd, rangeinitia #ifdef PY_CAN_RECURSE pygilstate = PyGILState_Ensure(); #else - Python_RestoreThread(); /* enter python */ + Python_RestoreThread(); // enter python #endif run((char *) cmd, arg @@ -1080,7 +1075,7 @@ DoPyCommand(const char *cmd, rangeinitia #ifdef PY_CAN_RECURSE PyGILState_Release(pygilstate); #else - Python_SaveThread(); /* leave python */ + Python_SaveThread(); // leave python #endif #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) @@ -1091,7 +1086,7 @@ DoPyCommand(const char *cmd, rangeinitia } #endif - Python_Lock_Vim(); /* enter vim */ + Python_Lock_Vim(); // enter vim PythonIO_Flush(); theend: @@ -1138,17 +1133,16 @@ ex_pyfile(exarg_T *eap) if (p_pyx == 0) p_pyx = 2; - /* Have to do it like this. PyRun_SimpleFile requires you to pass a - * stdio file pointer, but Vim and the Python DLL are compiled with - * different options under Windows, meaning that stdio pointers aren't - * compatible between the two. Yuk. - * - * Put the string "execfile('file')" into buffer. But, we need to - * escape any backslashes or single quotes in the file name, so that - * Python won't mangle the file name. - */ + // Have to do it like this. PyRun_SimpleFile requires you to pass a + // stdio file pointer, but Vim and the Python DLL are compiled with + // different options under Windows, meaning that stdio pointers aren't + // compatible between the two. Yuk. + // + // Put the string "execfile('file')" into buffer. But, we need to + // escape any backslashes or single quotes in the file name, so that + // Python won't mangle the file name. strcpy(buffer, "execfile('"); - p = buffer + 10; /* size of "execfile('" */ + p = buffer + 10; // size of "execfile('" while (*file && p < buffer + (BUFFER_SIZE - 3)) { @@ -1157,16 +1151,16 @@ ex_pyfile(exarg_T *eap) *p++ = *file++; } - /* If we didn't finish the file name, we hit a buffer overflow */ + // If we didn't finish the file name, we hit a buffer overflow if (*file != '\0') return; - /* Put in the terminating "')" and a null */ + // Put in the terminating "')" and a null *p++ = '\''; *p++ = ')'; *p++ = '\0'; - /* Execute the file */ + // Execute the file DoPyCommand(buffer, (rangeinitializer) init_range_cmd, (runner) run_cmd, @@ -1185,12 +1179,10 @@ ex_pydo(exarg_T *eap) (void *)eap); } -/****************************************************** - * 2. Python output stream: writes output via [e]msg(). - */ +/////////////////////////////////////////////////////// +// 2. Python output stream: writes output via [e]msg(). -/* Implementation functions - */ +// Implementation functions static PyObject * OutputGetattr(PyObject *self, char *name) @@ -1206,53 +1198,47 @@ OutputGetattr(PyObject *self, char *name return Py_FindMethod(OutputMethods, self, name); } -/****************************************************** - * 3. Implementation of the Vim module for Python - */ +/////////////////////////////////////////////////////// +// 3. Implementation of the Vim module for Python -/* Window type - Implementation functions - * -------------------------------------- - */ +// Window type - Implementation functions +// -------------------------------------- #define WindowType_Check(obj) ((obj)->ob_type == &WindowType) -/* Buffer type - Implementation functions - * -------------------------------------- - */ +// Buffer type - Implementation functions +// -------------------------------------- #define BufferType_Check(obj) ((obj)->ob_type == &BufferType) static PyInt BufferAssItem(PyObject *, PyInt, PyObject *); static PyInt BufferAssSlice(PyObject *, PyInt, PyInt, PyObject *); -/* Line range type - Implementation functions - * -------------------------------------- - */ +// Line range type - Implementation functions +// -------------------------------------- #define RangeType_Check(obj) ((obj)->ob_type == &RangeType) static PyInt RangeAssItem(PyObject *, PyInt, PyObject *); static PyInt RangeAssSlice(PyObject *, PyInt, PyInt, PyObject *); -/* Current objects type - Implementation functions - * ----------------------------------------------- - */ +// Current objects type - Implementation functions +// ----------------------------------------------- static PySequenceMethods BufferAsSeq = { - (PyInquiry) BufferLength, /* sq_length, len(x) */ - (binaryfunc) 0, /* BufferConcat, sq_concat, x+y */ - (PyIntArgFunc) 0, /* BufferRepeat, sq_repeat, x*n */ - (PyIntArgFunc) BufferItem, /* sq_item, x[i] */ - (PyIntIntArgFunc) BufferSlice, /* sq_slice, x[i:j] */ - (PyIntObjArgProc) BufferAssItem, /* sq_ass_item, x[i]=v */ - (PyIntIntObjArgProc) BufferAssSlice, /* sq_ass_slice, x[i:j]=v */ + (PyInquiry) BufferLength, // sq_length, len(x) + (binaryfunc) 0, // BufferConcat, sq_concat, x+y + (PyIntArgFunc) 0, // BufferRepeat, sq_repeat, x*n + (PyIntArgFunc) BufferItem, // sq_item, x[i] + (PyIntIntArgFunc) BufferSlice, // sq_slice, x[i:j] + (PyIntObjArgProc) BufferAssItem, // sq_ass_item, x[i]=v + (PyIntIntObjArgProc) BufferAssSlice, // sq_ass_slice, x[i:j]=v (objobjproc) 0, (binaryfunc) 0, 0, }; -/* Buffer object - Implementation - */ +// Buffer object - Implementation static PyObject * BufferGetattr(PyObject *self, char *name) @@ -1272,7 +1258,7 @@ BufferGetattr(PyObject *self, char *name return Py_FindMethod(BufferMethods, self, name); } -/******************/ +////////////////// static PyInt BufferAssItem(PyObject *self, PyInt n, PyObject *val) @@ -1287,13 +1273,13 @@ BufferAssSlice(PyObject *self, PyInt lo, } static PySequenceMethods RangeAsSeq = { - (PyInquiry) RangeLength, /* sq_length, len(x) */ - (binaryfunc) 0, /* RangeConcat, */ /* sq_concat, x+y */ - (PyIntArgFunc) 0, /* RangeRepeat, */ /* sq_repeat, x*n */ - (PyIntArgFunc) RangeItem, /* sq_item, x[i] */ - (PyIntIntArgFunc) RangeSlice, /* sq_slice, x[i:j] */ - (PyIntObjArgProc) RangeAssItem, /* sq_ass_item, x[i]=v */ - (PyIntIntObjArgProc) RangeAssSlice, /* sq_ass_slice, x[i:j]=v */ + (PyInquiry) RangeLength, // sq_length, len(x) + (binaryfunc) 0, /* RangeConcat, */ // sq_concat, x+y + (PyIntArgFunc) 0, /* RangeRepeat, */ // sq_repeat, x*n + (PyIntArgFunc) RangeItem, // sq_item, x[i] + (PyIntIntArgFunc) RangeSlice, // sq_slice, x[i:j] + (PyIntObjArgProc) RangeAssItem, // sq_ass_item, x[i]=v + (PyIntIntObjArgProc) RangeAssSlice, // sq_ass_slice, x[i:j]=v (objobjproc) 0, #if PY_MAJOR_VERSION >= 2 (binaryfunc) 0, @@ -1301,8 +1287,7 @@ static PySequenceMethods RangeAsSeq = { #endif }; -/* Line range object - Implementation - */ +// Line range object - Implementation static PyObject * RangeGetattr(PyObject *self, char *name) @@ -1317,7 +1302,7 @@ RangeGetattr(PyObject *self, char *name) return Py_FindMethod(RangeMethods, self, name); } -/****************/ +//////////////// static PyInt RangeAssItem(PyObject *self, PyInt n, PyObject *val) @@ -1337,8 +1322,7 @@ RangeAssSlice(PyObject *self, PyInt lo, &((RangeObject *)(self))->end); } -/* TabPage object - Implementation - */ +// TabPage object - Implementation static PyObject * TabPageGetattr(PyObject *self, char *name) @@ -1358,8 +1342,7 @@ TabPageGetattr(PyObject *self, char *nam return Py_FindMethod(TabPageMethods, self, name); } -/* Window object - Implementation - */ +// Window object - Implementation static PyObject * WindowGetattr(PyObject *self, char *name) @@ -1379,17 +1362,16 @@ WindowGetattr(PyObject *self, char *name return Py_FindMethod(WindowMethods, self, name); } -/* Tab page list object - Definitions - */ +// Tab page list object - Definitions static PySequenceMethods TabListAsSeq = { - (PyInquiry) TabListLength, /* sq_length, len(x) */ - (binaryfunc) 0, /* sq_concat, x+y */ - (PyIntArgFunc) 0, /* sq_repeat, x*n */ - (PyIntArgFunc) TabListItem, /* sq_item, x[i] */ - (PyIntIntArgFunc) 0, /* sq_slice, x[i:j] */ - (PyIntObjArgProc) 0, /* sq_ass_item, x[i]=v */ - (PyIntIntObjArgProc) 0, /* sq_ass_slice, x[i:j]=v */ + (PyInquiry) TabListLength, // sq_length, len(x) + (binaryfunc) 0, // sq_concat, x+y + (PyIntArgFunc) 0, // sq_repeat, x*n + (PyIntArgFunc) TabListItem, // sq_item, x[i] + (PyIntIntArgFunc) 0, // sq_slice, x[i:j] + (PyIntObjArgProc) 0, // sq_ass_item, x[i]=v + (PyIntIntObjArgProc) 0, // sq_ass_slice, x[i:j]=v (objobjproc) 0, #if PY_MAJOR_VERSION >= 2 (binaryfunc) 0, @@ -1397,17 +1379,16 @@ static PySequenceMethods TabListAsSeq = #endif }; -/* Window list object - Definitions - */ +// Window list object - Definitions static PySequenceMethods WinListAsSeq = { - (PyInquiry) WinListLength, /* sq_length, len(x) */ - (binaryfunc) 0, /* sq_concat, x+y */ - (PyIntArgFunc) 0, /* sq_repeat, x*n */ - (PyIntArgFunc) WinListItem, /* sq_item, x[i] */ - (PyIntIntArgFunc) 0, /* sq_slice, x[i:j] */ - (PyIntObjArgProc) 0, /* sq_ass_item, x[i]=v */ - (PyIntIntObjArgProc) 0, /* sq_ass_slice, x[i:j]=v */ + (PyInquiry) WinListLength, // sq_length, len(x) + (binaryfunc) 0, // sq_concat, x+y + (PyIntArgFunc) 0, // sq_repeat, x*n + (PyIntArgFunc) WinListItem, // sq_item, x[i] + (PyIntIntArgFunc) 0, // sq_slice, x[i:j] + (PyIntObjArgProc) 0, // sq_ass_item, x[i]=v + (PyIntIntObjArgProc) 0, // sq_ass_slice, x[i:j]=v (objobjproc) 0, #if PY_MAJOR_VERSION >= 2 (binaryfunc) 0, @@ -1415,8 +1396,7 @@ static PySequenceMethods WinListAsSeq = #endif }; -/* External interface - */ +// External interface void python_buffer_free(buf_T *buf) @@ -1454,13 +1434,13 @@ python_tabpage_free(tabpage_T *tab) static int PythonMod_Init(void) { - /* The special value is removed from sys.path in Python_Init(). */ + // The special value is removed from sys.path in Python_Init(). static char *(argv[2]) = {"/must>not&exist/foo", NULL}; if (init_types()) return -1; - /* Set sys.argv[] to avoid a crash in warn(). */ + // Set sys.argv[] to avoid a crash in warn(). PySys_SetArgv(1, argv); vim_module = Py_InitModule4("vim", VimMethods, (char *)NULL, @@ -1475,15 +1455,13 @@ PythonMod_Init(void) return 0; } -/************************************************************************* - * 4. Utility functions for handling the interface between Vim and Python. - */ +////////////////////////////////////////////////////////////////////////// +// 4. Utility functions for handling the interface between Vim and Python. -/* Convert a Vim line into a Python string. - * All internal newlines are replaced by null characters. - * - * On errors, the Python exception data is set, and NULL is returned. - */ +// Convert a Vim line into a Python string. +// All internal newlines are replaced by null characters. +// +// On errors, the Python exception data is set, and NULL is returned. static PyObject * LineToString(const char *str) { @@ -1491,10 +1469,9 @@ LineToString(const char *str) PyInt len = strlen(str); char *p; - /* Allocate an Python string object, with uninitialised contents. We - * must do it this way, so that we can modify the string in place - * later. See the Python source, Objects/stringobject.c for details. - */ + // Allocate an Python string object, with uninitialised contents. We + // must do it this way, so that we can modify the string in place + // later. See the Python source, Objects/stringobject.c for details. result = PyString_FromStringAndSize(NULL, len); if (result == NULL) return NULL; @@ -1568,8 +1545,8 @@ do_pyeval(char_u *str, typval_T *rettv) } } -/* Don't generate a prototype for the next function, it generates an error on - * newer Python versions. */ +// Don't generate a prototype for the next function, it generates an error on +// newer Python versions. #if PYTHON_API_VERSION < 1007 /* Python 1.4 */ && !defined(PROTO) char * @@ -1577,7 +1554,7 @@ Py_GetProgramName(void) { return "vim"; } -#endif /* Python 1.4 */ +#endif // Python 1.4 int set_ref_in_python(int copyID)
--- a/src/if_python3.c +++ b/src/if_python3.c @@ -22,13 +22,12 @@ * Adaptations to support both python3.x and python2.x */ -/* uncomment this if used with the debug version of python */ -/* #define Py_DEBUG */ -/* Note: most of time you can add -DPy_DEBUG to CFLAGS in place of uncommenting - */ -/* uncomment this if used with the debug version of python, but without its - * allocator */ -/* #define Py_DEBUG_NO_PYMALLOC */ +// uncomment this if used with the debug version of python +// #define Py_DEBUG +// Note: most of time you can add -DPy_DEBUG to CFLAGS in place of uncommenting +// uncomment this if used with the debug version of python, but without its +// allocator +// #define Py_DEBUG_NO_PYMALLOC #include "vim.h" @@ -56,30 +55,30 @@ # undef HAVE_PUTENV #endif #ifdef HAVE_STDARG_H -# undef HAVE_STDARG_H /* Python's config.h defines it as well. */ +# undef HAVE_STDARG_H // Python's config.h defines it as well. #endif -#ifdef _POSIX_C_SOURCE /* defined in feature.h */ +#ifdef _POSIX_C_SOURCE // defined in feature.h # undef _POSIX_C_SOURCE #endif #ifdef _XOPEN_SOURCE -# undef _XOPEN_SOURCE /* pyconfig.h defines it as well. */ +# undef _XOPEN_SOURCE // pyconfig.h defines it as well. #endif #define PY_SSIZE_T_CLEAN #include <Python.h> -#undef main /* Defined in python.h - aargh */ -#undef HAVE_FCNTL_H /* Clash with os_win32.h */ +#undef main // Defined in python.h - aargh +#undef HAVE_FCNTL_H // Clash with os_win32.h -/* The "surrogateescape" error handler is new in Python 3.1 */ +// The "surrogateescape" error handler is new in Python 3.1 #if PY_VERSION_HEX >= 0x030100f0 # define CODEC_ERROR_HANDLER "surrogateescape" #else # define CODEC_ERROR_HANDLER NULL #endif -/* Python 3 does not support CObjects, always use Capsules */ +// Python 3 does not support CObjects, always use Capsules #define PY_USE_CAPSULE #define PyInt Py_ssize_t @@ -432,9 +431,9 @@ static void(*py3_PyObject_GC_Del)(void * static void(*py3_PyObject_GC_UnTrack)(void *); static int (*py3_PyType_IsSubtype)(PyTypeObject *, PyTypeObject *); -static HINSTANCE hinstPy3 = 0; /* Instance of python.dll */ +static HINSTANCE hinstPy3 = 0; // Instance of python.dll -/* Imported exception objects */ +// Imported exception objects static PyObject *p3imp_PyExc_AttributeError; static PyObject *p3imp_PyExc_IndexError; static PyObject *p3imp_PyExc_KeyError; @@ -664,9 +663,9 @@ py3_runtime_link_init(char *libname, int (PYTHON_PROC *)&py3_PyUnicode_AsEncodedString; # if !(defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)) && defined(UNIX) && defined(FEAT_PYTHON) - /* Can't have Python and Python3 loaded at the same time. - * It cause a crash, because RTLD_GLOBAL is needed for - * standard C extension libraries of one or both python versions. */ + // Can't have Python and Python3 loaded at the same time. + // It cause a crash, because RTLD_GLOBAL is needed for + // standard C extension libraries of one or both python versions. if (python_loaded()) { if (verbose) @@ -699,8 +698,8 @@ py3_runtime_link_init(char *libname, int } } - /* Load unicode functions separately as only the ucs2 or the ucs4 functions - * will be present in the library. */ + // Load unicode functions separately as only the ucs2 or the ucs4 functions + // will be present in the library. # if PY_VERSION_HEX >= 0x030300f0 *ucs_from_string = symbol_from_dll(hinstPy3, "PyUnicode_FromString"); *ucs_decode = symbol_from_dll(hinstPy3, "PyUnicode_Decode"); @@ -746,7 +745,8 @@ python3_enabled(int verbose) return py3_runtime_link_init((char *)p_py3dll, verbose) == OK; } -/* Load the standard Python exceptions - don't import the symbols from the +/* + * Load the standard Python exceptions - don't import the symbols from the * DLL, as this can cause errors (importing data symbols is not reliable). */ static void @@ -776,7 +776,7 @@ get_py3_exceptions(void) Py_XINCREF(p3imp_PyExc_OverflowError); Py_XDECREF(exmod); } -#endif /* DYNAMIC_PYTHON3 */ +#endif // DYNAMIC_PYTHON3 static int py3initialised = 0; #define PYINITIALISED py3initialised @@ -843,22 +843,20 @@ static struct PyModuleDef vimmodule; #define PY3OBJ_DELETED(obj) (obj->ob_base.ob_refcnt<=0) -/****************************************************** - * Internal function prototypes. - */ +/////////////////////////////////////////////////////// +// Internal function prototypes. static PyObject *Py3Init_vim(void); -/****************************************************** - * 1. Python interpreter main program. - */ +/////////////////////////////////////////////////////// +// 1. Python interpreter main program. void python3_end(void) { static int recurse = 0; - /* If a crash occurs while doing this, don't try again. */ + // If a crash occurs while doing this, don't try again. if (recurse != 0) return; @@ -870,7 +868,7 @@ python3_end(void) #endif if (Py_IsInitialized()) { - /* acquire lock before finalizing */ + // acquire lock before finalizing PyGILState_Ensure(); Py_Finalize(); @@ -912,7 +910,7 @@ Python3_Init(void) { size_t len = mbstowcs(NULL, (char *)p_py3home, 0) + 1; - /* The string must not change later, make a copy in static memory. */ + // The string must not change later, make a copy in static memory. py_home_buf = ALLOC_MULT(wchar_t, len); if (py_home_buf != NULL && mbstowcs( py_home_buf, (char *)p_py3home, len) != (size_t)-1) @@ -927,10 +925,10 @@ Python3_Init(void) Py_Initialize(); - /* Initialise threads, and below save the state using - * PyEval_SaveThread. Without the call to PyEval_SaveThread, thread - * specific state (such as the system trace hook), will be lost - * between invocations of Python code. */ + // Initialise threads, and below save the state using + // PyEval_SaveThread. Without the call to PyEval_SaveThread, thread + // specific state (such as the system trace hook), will be lost + // between invocations of Python code. PyEval_InitThreads(); #ifdef DYNAMIC_PYTHON3 get_py3_exceptions(); @@ -941,22 +939,20 @@ Python3_Init(void) globals = PyModule_GetDict(PyImport_AddModule("__main__")); - /* Remove the element from sys.path that was added because of our - * argv[0] value in Py3Init_vim(). Previously we used an empty - * string, but depending on the OS we then get an empty entry or - * the current directory in sys.path. - * Only after vim has been imported, the element does exist in - * sys.path. - */ + // Remove the element from sys.path that was added because of our + // argv[0] value in Py3Init_vim(). Previously we used an empty + // string, but depending on the OS we then get an empty entry or + // the current directory in sys.path. + // Only after vim has been imported, the element does exist in + // sys.path. PyRun_SimpleString("import vim; import sys; sys.path = list(filter(lambda x: not x.endswith('must>not&exist'), sys.path))"); - /* lock is created and acquired in PyEval_InitThreads() and thread - * state is created in Py_Initialize() - * there _PyGILState_NoteThreadState() also sets gilcounter to 1 - * (python must have threads enabled!) - * so the following does both: unlock GIL and save thread state in TLS - * without deleting thread state - */ + // lock is created and acquired in PyEval_InitThreads() and thread + // state is created in Py_Initialize() + // there _PyGILState_NoteThreadState() also sets gilcounter to 1 + // (python must have threads enabled!) + // so the following does both: unlock GIL and save thread state in TLS + // without deleting thread state PyEval_SaveThread(); py3initialised = 1; @@ -965,11 +961,10 @@ Python3_Init(void) return 0; fail: - /* We call PythonIO_Flush() here to print any Python errors. - * This is OK, as it is possible to call this function even - * if PythonIO_Init_io() has not completed successfully (it will - * not do anything in this case). - */ + // We call PythonIO_Flush() here to print any Python errors. + // This is OK, as it is possible to call this function even + // if PythonIO_Init_io() has not completed successfully (it will + // not do anything in this case). PythonIO_Flush(); return -1; } @@ -995,16 +990,16 @@ DoPyCommand(const char *cmd, rangeinitia init_range(arg); - Python_Release_Vim(); /* leave vim */ + Python_Release_Vim(); // leave Vim #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) - /* Python only works properly when the LC_NUMERIC locale is "C". */ + // Python only works properly when the LC_NUMERIC locale is "C". saved_locale = setlocale(LC_NUMERIC, NULL); if (saved_locale == NULL || STRCMP(saved_locale, "C") == 0) saved_locale = NULL; else { - /* Need to make a copy, value may change when setting new locale. */ + // Need to make a copy, value may change when setting new locale. saved_locale = (char *)vim_strsave((char_u *)saved_locale); (void)setlocale(LC_NUMERIC, "C"); } @@ -1012,8 +1007,8 @@ DoPyCommand(const char *cmd, rangeinitia pygilstate = PyGILState_Ensure(); - /* PyRun_SimpleString expects a UTF-8 string. Wrong encoding may cause - * SyntaxError (unicode error). */ + // PyRun_SimpleString expects a UTF-8 string. Wrong encoding may cause + // SyntaxError (unicode error). cmdstr = PyUnicode_Decode(cmd, strlen(cmd), (char *)ENC_OPT, CODEC_ERROR_HANDLER); cmdbytes = PyUnicode_AsEncodedString(cmdstr, "utf-8", CODEC_ERROR_HANDLER); @@ -1032,11 +1027,11 @@ DoPyCommand(const char *cmd, rangeinitia } #endif - Python_Lock_Vim(); /* enter vim */ + Python_Lock_Vim(); // enter Vim PythonIO_Flush(); theend: - return; /* keeps lint happy */ + return; // keeps lint happy } /* @@ -1077,22 +1072,21 @@ ex_py3file(exarg_T *eap) if (p_pyx == 0) p_pyx = 3; - /* Have to do it like this. PyRun_SimpleFile requires you to pass a - * stdio file pointer, but Vim and the Python DLL are compiled with - * different options under Windows, meaning that stdio pointers aren't - * compatible between the two. Yuk. - * - * construct: exec(compile(open('a_filename', 'rb').read(), 'a_filename', 'exec')) - * - * Using bytes so that Python can detect the source encoding as it normally - * does. The doc does not say "compile" accept bytes, though. - * - * We need to escape any backslashes or single quotes in the file name, so that - * Python won't mangle the file name. - */ + // Have to do it like this. PyRun_SimpleFile requires you to pass a + // stdio file pointer, but Vim and the Python DLL are compiled with + // different options under Windows, meaning that stdio pointers aren't + // compatible between the two. Yuk. + // + // construct: exec(compile(open('a_filename', 'rb').read(), 'a_filename', 'exec')) + // + // Using bytes so that Python can detect the source encoding as it normally + // does. The doc does not say "compile" accept bytes, though. + // + // We need to escape any backslashes or single quotes in the file name, so that + // Python won't mangle the file name. strcpy(buffer, "exec(compile(open('"); - p = buffer + 19; /* size of "exec(compile(open('" */ + p = buffer + 19; // size of "exec(compile(open('" for (i=0; i<2; ++i) { @@ -1103,7 +1097,7 @@ ex_py3file(exarg_T *eap) *p++ = '\\'; *p++ = *file++; } - /* If we didn't finish the file name, we hit a buffer overflow */ + // If we didn't finish the file name, we hit a buffer overflow if (*file != '\0') return; if (i==0) @@ -1119,7 +1113,7 @@ ex_py3file(exarg_T *eap) } - /* Execute the file */ + // Execute the file DoPyCommand(buffer, (rangeinitializer) init_range_cmd, (runner) run_cmd, @@ -1138,12 +1132,10 @@ ex_py3do(exarg_T *eap) (void *)eap); } -/****************************************************** - * 2. Python output stream: writes output via [e]msg(). - */ +/////////////////////////////////////////////////////// +// 2. Python output stream: writes output via [e]msg(). -/* Implementation functions - */ +// Implementation functions static PyObject * OutputGetattro(PyObject *self, PyObject *nameobj) @@ -1168,28 +1160,24 @@ OutputSetattro(PyObject *self, PyObject return OutputSetattr((OutputObject *)(self), name, val); } -/****************************************************** - * 3. Implementation of the Vim module for Python - */ +/////////////////////////////////////////////////////// +// 3. Implementation of the Vim module for Python -/* Window type - Implementation functions - * -------------------------------------- - */ +// Window type - Implementation functions +// -------------------------------------- #define WindowType_Check(obj) ((obj)->ob_base.ob_type == &WindowType) -/* Buffer type - Implementation functions - * -------------------------------------- - */ +// Buffer type - Implementation functions +// -------------------------------------- #define BufferType_Check(obj) ((obj)->ob_base.ob_type == &BufferType) static PyObject* BufferSubscript(PyObject *self, PyObject *idx); static Py_ssize_t BufferAsSubscript(PyObject *self, PyObject *idx, PyObject *val); -/* Line range type - Implementation functions - * -------------------------------------- - */ +// Line range type - Implementation functions +// -------------------------------------- #define RangeType_Check(obj) ((obj)->ob_base.ob_type == &RangeType) @@ -1197,21 +1185,20 @@ static PyObject* RangeSubscript(PyObject static Py_ssize_t RangeAsItem(PyObject *, Py_ssize_t, PyObject *); static Py_ssize_t RangeAsSubscript(PyObject *self, PyObject *idx, PyObject *val); -/* Current objects type - Implementation functions - * ----------------------------------------------- - */ +// Current objects type - Implementation functions +// ----------------------------------------------- static PySequenceMethods BufferAsSeq = { - (lenfunc) BufferLength, /* sq_length, len(x) */ - (binaryfunc) 0, /* sq_concat, x+y */ - (ssizeargfunc) 0, /* sq_repeat, x*n */ - (ssizeargfunc) BufferItem, /* sq_item, x[i] */ - 0, /* was_sq_slice, x[i:j] */ - 0, /* sq_ass_item, x[i]=v */ - 0, /* sq_ass_slice, x[i:j]=v */ - 0, /* sq_contains */ - 0, /* sq_inplace_concat */ - 0, /* sq_inplace_repeat */ + (lenfunc) BufferLength, // sq_length, len(x) + (binaryfunc) 0, // sq_concat, x+y + (ssizeargfunc) 0, // sq_repeat, x*n + (ssizeargfunc) BufferItem, // sq_item, x[i] + 0, // was_sq_slice, x[i:j] + 0, // sq_ass_item, x[i]=v + 0, // sq_ass_slice, x[i:j]=v + 0, // sq_contains + 0, // sq_inplace_concat + 0, // sq_inplace_repeat }; static PyMappingMethods BufferAsMapping = { @@ -1221,8 +1208,7 @@ static PyMappingMethods BufferAsMapping }; -/* Buffer object - */ +// Buffer object static PyObject * BufferGetattro(PyObject *self, PyObject *nameobj) @@ -1252,7 +1238,7 @@ BufferSetattro(PyObject *self, PyObject return BufferSetattr((BufferObject *)(self), name, val); } -/******************/ +////////////////// static PyObject * BufferSubscript(PyObject *self, PyObject* idx) @@ -1315,16 +1301,16 @@ BufferAsSubscript(PyObject *self, PyObje } static PySequenceMethods RangeAsSeq = { - (lenfunc) RangeLength, /* sq_length, len(x) */ - (binaryfunc) 0, /* RangeConcat, sq_concat, x+y */ - (ssizeargfunc) 0, /* RangeRepeat, sq_repeat, x*n */ - (ssizeargfunc) RangeItem, /* sq_item, x[i] */ - 0, /* was_sq_slice, x[i:j] */ - (ssizeobjargproc) RangeAsItem, /* sq_as_item, x[i]=v */ - 0, /* sq_ass_slice, x[i:j]=v */ - 0, /* sq_contains */ - 0, /* sq_inplace_concat */ - 0, /* sq_inplace_repeat */ + (lenfunc) RangeLength, // sq_length, len(x) + (binaryfunc) 0, // RangeConcat, sq_concat, x+y + (ssizeargfunc) 0, // RangeRepeat, sq_repeat, x*n + (ssizeargfunc) RangeItem, // sq_item, x[i] + 0, // was_sq_slice, x[i:j] + (ssizeobjargproc) RangeAsItem, // sq_as_item, x[i]=v + 0, // sq_ass_slice, x[i:j]=v + 0, // sq_contains + 0, // sq_inplace_concat + 0, // sq_inplace_repeat }; static PyMappingMethods RangeAsMapping = { @@ -1333,8 +1319,7 @@ static PyMappingMethods RangeAsMapping = /* mp_ass_subscript */ (objobjargproc)RangeAsSubscript, }; -/* Line range object - Implementation - */ +// Line range object - Implementation static PyObject * RangeGetattro(PyObject *self, PyObject *nameobj) @@ -1349,7 +1334,7 @@ RangeGetattro(PyObject *self, PyObject * return PyObject_GenericGetAttr(self, nameobj); } -/****************/ +//////////////// static Py_ssize_t RangeAsItem(PyObject *self, Py_ssize_t n, PyObject *val) @@ -1420,8 +1405,7 @@ RangeAsSubscript(PyObject *self, PyObjec } } -/* TabPage object - Implementation - */ +// TabPage object - Implementation static PyObject * TabPageGetattro(PyObject *self, PyObject *nameobj) @@ -1443,8 +1427,7 @@ TabPageGetattro(PyObject *self, PyObject return PyObject_GenericGetAttr(self, nameobj); } -/* Window object - Implementation - */ +// Window object - Implementation static PyObject * WindowGetattro(PyObject *self, PyObject *nameobj) @@ -1474,39 +1457,38 @@ WindowSetattro(PyObject *self, PyObject return WindowSetattr((WindowObject *)(self), name, val); } -/* Tab page list object - Definitions - */ +// Tab page list object - Definitions static PySequenceMethods TabListAsSeq = { - (lenfunc) TabListLength, /* sq_length, len(x) */ - (binaryfunc) 0, /* sq_concat, x+y */ - (ssizeargfunc) 0, /* sq_repeat, x*n */ - (ssizeargfunc) TabListItem, /* sq_item, x[i] */ - 0, /* sq_slice, x[i:j] */ - (ssizeobjargproc)0, /* sq_as_item, x[i]=v */ - 0, /* sq_ass_slice, x[i:j]=v */ - 0, /* sq_contains */ - 0, /* sq_inplace_concat */ - 0, /* sq_inplace_repeat */ + (lenfunc) TabListLength, // sq_length, len(x) + (binaryfunc) 0, // sq_concat, x+y + (ssizeargfunc) 0, // sq_repeat, x*n + (ssizeargfunc) TabListItem, // sq_item, x[i] + 0, // sq_slice, x[i:j] + (ssizeobjargproc)0, // sq_as_item, x[i]=v + 0, // sq_ass_slice, x[i:j]=v + 0, // sq_contains + 0, // sq_inplace_concat + 0, // sq_inplace_repeat }; -/* Window list object - Definitions - */ +// Window list object - Definitions static PySequenceMethods WinListAsSeq = { - (lenfunc) WinListLength, /* sq_length, len(x) */ - (binaryfunc) 0, /* sq_concat, x+y */ - (ssizeargfunc) 0, /* sq_repeat, x*n */ - (ssizeargfunc) WinListItem, /* sq_item, x[i] */ - 0, /* sq_slice, x[i:j] */ - (ssizeobjargproc)0, /* sq_as_item, x[i]=v */ - 0, /* sq_ass_slice, x[i:j]=v */ - 0, /* sq_contains */ - 0, /* sq_inplace_concat */ - 0, /* sq_inplace_repeat */ + (lenfunc) WinListLength, // sq_length, len(x) + (binaryfunc) 0, // sq_concat, x+y + (ssizeargfunc) 0, // sq_repeat, x*n + (ssizeargfunc) WinListItem, // sq_item, x[i] + 0, // sq_slice, x[i:j] + (ssizeobjargproc)0, // sq_as_item, x[i]=v + 0, // sq_ass_slice, x[i:j]=v + 0, // sq_contains + 0, // sq_inplace_concat + 0, // sq_inplace_repeat }; -/* Current items object - Implementation +/* + * Current items object - Implementation */ static PyObject * CurrentGetattro(PyObject *self, PyObject *nameobj) @@ -1525,8 +1507,7 @@ CurrentSetattro(PyObject *self, PyObject return CurrentSetattr(self, name, value); } -/* Dictionary object - Definitions - */ +// Dictionary object - Definitions static PyObject * DictionaryGetattro(PyObject *self, PyObject *nameobj) @@ -1550,8 +1531,7 @@ DictionarySetattro(PyObject *self, PyObj return DictionarySetattr((DictionaryObject *)(self), name, val); } -/* List object - Definitions - */ +// List object - Definitions static PyObject * ListGetattro(PyObject *self, PyObject *nameobj) @@ -1571,8 +1551,7 @@ ListSetattro(PyObject *self, PyObject *n return ListSetattr((ListObject *)(self), name, val); } -/* Function object - Definitions - */ +// Function object - Definitions static PyObject * FunctionGetattro(PyObject *self, PyObject *nameobj) @@ -1589,8 +1568,7 @@ FunctionGetattro(PyObject *self, PyObjec return PyObject_GenericGetAttr(self, nameobj); } -/* External interface - */ +// External interface void python3_buffer_free(buf_T *buf) @@ -1628,13 +1606,13 @@ python3_tabpage_free(tabpage_T *tab) static PyObject * Py3Init_vim(void) { - /* The special value is removed from sys.path in Python3_Init(). */ + // The special value is removed from sys.path in Python3_Init(). static wchar_t *(argv[2]) = {L"/must>not&exist/foo", NULL}; if (init_types()) return NULL; - /* Set sys.argv[] to avoid a crash in warn(). */ + // Set sys.argv[] to avoid a crash in warn(). PySys_SetArgv(1, argv); if ((vim_module = PyModule_Create(&vimmodule)) == NULL) @@ -1649,11 +1627,11 @@ Py3Init_vim(void) return vim_module; } -/************************************************************************* - * 4. Utility functions for handling the interface between Vim and Python. - */ +////////////////////////////////////////////////////////////////////////// +// 4. Utility functions for handling the interface between Vim and Python. -/* Convert a Vim line into a Python string. +/* + * Convert a Vim line into a Python string. * All internal newlines are replaced by null characters. * * On errors, the Python exception data is set, and NULL is returned.
--- a/src/if_ruby.c +++ b/src/if_ruby.c @@ -24,7 +24,7 @@ # define NT # endif # ifndef DYNAMIC_RUBY -# define IMPORT /* For static dll usage __declspec(dllimport) */ +# define IMPORT // For static dll usage __declspec(dllimport) # define RUBYEXTERN __declspec(dllimport) # endif #endif @@ -87,23 +87,23 @@ #endif #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19 -/* Ruby 1.9 defines a number of static functions which use rb_num2long and - * rb_int2big */ +// Ruby 1.9 defines a number of static functions which use rb_num2long and +// rb_int2big # define rb_num2long rb_num2long_stub # define rb_int2big rb_int2big_stub #endif #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19 \ && VIM_SIZEOF_INT < VIM_SIZEOF_LONG -/* Ruby 1.9 defines a number of static functions which use rb_fix2int and - * rb_num2int if VIM_SIZEOF_INT < VIM_SIZEOF_LONG (64bit) */ +// Ruby 1.9 defines a number of static functions which use rb_fix2int and +// rb_num2int if VIM_SIZEOF_INT < VIM_SIZEOF_LONG (64bit) # define rb_fix2int rb_fix2int_stub # define rb_num2int rb_num2int_stub #endif #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER == 21 -/* Ruby 2.1 adds new GC called RGenGC and RARRAY_PTR uses - * rb_gc_writebarrier_unprotect_promoted if USE_RGENGC */ +// Ruby 2.1 adds new GC called RGenGC and RARRAY_PTR uses +// rb_gc_writebarrier_unprotect_promoted if USE_RGENGC # define rb_gc_writebarrier_unprotect_promoted rb_gc_writebarrier_unprotect_promoted_stub #endif #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 22 @@ -126,7 +126,7 @@ #undef EXTERN #undef _ -/* T_DATA defined both by Ruby and Mac header files, hack around it... */ +// T_DATA defined both by Ruby and Mac header files, hack around it... #if defined(MACOS_X) # define __OPENTRANSPORT__ # define __OPENTRANSPORTPROTOCOL__ @@ -189,7 +189,7 @@ #endif #if defined(PROTO) && !defined(FEAT_RUBY) -/* Define these to be able to generate the function prototypes. */ +// Define these to be able to generate the function prototypes. # define VALUE int # define RUBY_DATA_FUNC int #endif @@ -218,7 +218,7 @@ static int ruby_convert_to_vim_value(VAL #if defined(DYNAMIC_RUBY) || defined(PROTO) # if defined(PROTO) && !defined(HINSTANCE) -# define HINSTANCE int /* for generating prototypes */ +# define HINSTANCE int // for generating prototypes # endif /* @@ -273,7 +273,7 @@ static int ruby_convert_to_vim_value(VAL # undef rb_intern # define rb_intern dll_rb_intern -# if VIM_SIZEOF_INT < VIM_SIZEOF_LONG /* 64 bits only */ +# if VIM_SIZEOF_INT < VIM_SIZEOF_LONG // 64 bits only # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER <= 18 # define rb_fix2int dll_rb_fix2int # define rb_num2int dll_rb_num2int @@ -300,10 +300,10 @@ static int ruby_convert_to_vim_value(VAL # undef rb_str_new # define rb_str_new dll_rb_str_new # ifdef rb_str_new2 -/* Ruby may #define rb_str_new2 to use rb_str_new_cstr. */ +// Ruby may #define rb_str_new2 to use rb_str_new_cstr. # define need_rb_str_new_cstr 1 -/* Ruby's headers #define rb_str_new_cstr to make use of GCC's - * __builtin_constant_p extension. */ +// Ruby's headers #define rb_str_new_cstr to make use of GCC's +// __builtin_constant_p extension. # undef rb_str_new_cstr # define rb_str_new_cstr dll_rb_str_new_cstr # else @@ -420,7 +420,7 @@ static VALUE (*dll_rb_hash_new) (void); static VALUE (*dll_rb_inspect) (VALUE); static VALUE (*dll_rb_int2inum) (long); static ID (*dll_rb_intern) (const char*); -# if VIM_SIZEOF_INT < VIM_SIZEOF_LONG /* 64 bits only */ +# if VIM_SIZEOF_INT < VIM_SIZEOF_LONG // 64 bits only static long (*dll_rb_fix2int) (VALUE); static long (*dll_rb_num2int) (VALUE); static unsigned long (*dll_rb_num2uint) (VALUE); @@ -445,7 +445,7 @@ static VALUE (*dll_rb_str_cat) (VALUE, c static VALUE (*dll_rb_str_concat) (VALUE, VALUE); static VALUE (*dll_rb_str_new) (const char*, long); # ifdef need_rb_str_new_cstr -/* Ruby may #define rb_str_new2 to use rb_str_new_cstr. */ +// Ruby may #define rb_str_new2 to use rb_str_new_cstr. static VALUE (*dll_rb_str_new_cstr) (const char*); # else static VALUE (*dll_rb_str_new2) (const char*); @@ -560,7 +560,7 @@ rb_num2ulong(VALUE x) # endif # endif - /* Do not generate a prototype here, VALUE isn't always defined. */ + // Do not generate a prototype here, VALUE isn't always defined. # if defined(USE_RGENGC) && USE_RGENGC && !defined(PROTO) # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER == 21 void @@ -585,7 +585,7 @@ rb_ary_detransient_stub(VALUE x) } # endif -static HINSTANCE hinstRuby = NULL; /* Instance of ruby.dll */ +static HINSTANCE hinstRuby = NULL; // Instance of ruby.dll /* * Table of name to function pointer of ruby. @@ -653,7 +653,7 @@ static struct {"rb_inspect", (RUBY_PROC*)&dll_rb_inspect}, {"rb_int2inum", (RUBY_PROC*)&dll_rb_int2inum}, {"rb_intern", (RUBY_PROC*)&dll_rb_intern}, -# if VIM_SIZEOF_INT < VIM_SIZEOF_LONG /* 64 bits only */ +# if VIM_SIZEOF_INT < VIM_SIZEOF_LONG // 64 bits only {"rb_fix2int", (RUBY_PROC*)&dll_rb_fix2int}, {"rb_num2int", (RUBY_PROC*)&dll_rb_num2int}, {"rb_num2uint", (RUBY_PROC*)&dll_rb_num2uint}, @@ -800,7 +800,7 @@ ruby_enabled(int verbose) { return ruby_runtime_link_init((char *)p_rubydll, verbose) == OK; } -#endif /* defined(DYNAMIC_RUBY) || defined(PROTO) */ +#endif // defined(DYNAMIC_RUBY) || defined(PROTO) void ruby_end(void) @@ -918,7 +918,7 @@ ex_rubydo(exarg_T *eap) ml_replace(i, (char_u *) StringValuePtr(line), 1); changed(); #ifdef SYNTAX_HL - syn_changed(i); /* recompute syntax hl. for this line */ + syn_changed(i); // recompute syntax hl. for this line #endif } } @@ -978,7 +978,7 @@ ensure_ruby_initialized(void) { #endif #ifdef MSWIN - /* suggested by Ariya Mizutani */ + // suggested by Ariya Mizutani int argc = 1; char *argv[] = {"gvim.exe"}; char **argvp = argv; @@ -1112,7 +1112,7 @@ vim_message(VALUE self UNUSED, VALUE str str = rb_obj_as_string(str); if (RSTRING_LEN(str) > 0) { - /* Only do this when the string isn't empty, alloc(0) causes trouble. */ + // Only do this when the string isn't empty, alloc(0) causes trouble. buff = ALLOCA_N(char, RSTRING_LEN(str) + 1); strcpy(buff, RSTRING_PTR(str)); p = strchr(buff, '\n'); @@ -1211,7 +1211,7 @@ vim_to_ruby(typval_T *tv) result = rb_str_new(tv->vval.v_blob->bv_ga.ga_data, tv->vval.v_blob->bv_ga.ga_len); } - /* else return Qnil; */ + // else return Qnil; return result; } @@ -1319,8 +1319,8 @@ buffer_s_count(void) FOR_ALL_BUFFERS(b) { - /* Deleted buffers should not be counted - * SegPhault - 01/07/05 */ + // Deleted buffers should not be counted + // SegPhault - 01/07/05 if (b->b_p_bl) n++; } @@ -1336,8 +1336,8 @@ buffer_s_aref(VALUE self UNUSED, VALUE n FOR_ALL_BUFFERS(b) { - /* Deleted buffers should not be counted - * SegPhault - 01/07/05 */ + // Deleted buffers should not be counted + // SegPhault - 01/07/05 if (!b->b_p_bl) continue; @@ -1388,7 +1388,7 @@ buffer_aref(VALUE self, VALUE num) if (buf != NULL) return get_buffer_line(buf, (linenr_T)NUM2LONG(num)); - return Qnil; /* For stop warning */ + return Qnil; // For stop warning } static VALUE @@ -1399,7 +1399,7 @@ set_buffer_line(buf_T *buf, linenr_T n, if (n > 0 && n <= buf->b_ml.ml_line_count && line != NULL) { - /* set curwin/curbuf for "buf" and save some things */ + // set curwin/curbuf for "buf" and save some things aucmd_prepbuf(&aco, buf); if (u_savesub(n) == OK) @@ -1407,13 +1407,13 @@ set_buffer_line(buf_T *buf, linenr_T n, ml_replace(n, (char_u *)line, TRUE); changed(); #ifdef SYNTAX_HL - syn_changed(n); /* recompute syntax hl. for this line */ + syn_changed(n); // recompute syntax hl. for this line #endif } - /* restore curwin/curbuf and a few other things */ + // restore curwin/curbuf and a few other things aucmd_restbuf(&aco); - /* Careful: autocommands may have made "buf" invalid! */ + // Careful: autocommands may have made "buf" invalid! update_curbuf(NOT_VALID); } @@ -1443,23 +1443,23 @@ buffer_delete(VALUE self, VALUE num) if (n > 0 && n <= buf->b_ml.ml_line_count) { - /* set curwin/curbuf for "buf" and save some things */ + // set curwin/curbuf for "buf" and save some things aucmd_prepbuf(&aco, buf); if (u_savedel(n, 1) == OK) { ml_delete(n, 0); - /* Changes to non-active buffers should properly refresh - * SegPhault - 01/09/05 */ + // Changes to non-active buffers should properly refresh + // SegPhault - 01/09/05 deleted_lines_mark(n, 1L); changed(); } - /* restore curwin/curbuf and a few other things */ + // restore curwin/curbuf and a few other things aucmd_restbuf(&aco); - /* Careful: autocommands may have made "buf" invalid! */ + // Careful: autocommands may have made "buf" invalid! update_curbuf(NOT_VALID); } @@ -1484,23 +1484,23 @@ buffer_append(VALUE self, VALUE num, VAL } else if (n >= 0 && n <= buf->b_ml.ml_line_count) { - /* set curwin/curbuf for "buf" and save some things */ + // set curwin/curbuf for "buf" and save some things aucmd_prepbuf(&aco, buf); if (u_inssub(n + 1) == OK) { ml_append(n, (char_u *) line, (colnr_T) 0, FALSE); - /* Changes to non-active buffers should properly refresh screen - * SegPhault - 12/20/04 */ + // Changes to non-active buffers should properly refresh screen + // SegPhault - 12/20/04 appended_lines_mark(n, 1L); changed(); } - /* restore curwin/curbuf and a few other things */ + // restore curwin/curbuf and a few other things aucmd_restbuf(&aco); - /* Careful: autocommands may have made "buf" invalid! */ + // Careful: autocommands may have made "buf" invalid! update_curbuf(NOT_VALID); } @@ -1684,7 +1684,7 @@ window_set_cursor(VALUE self, VALUE pos) win->w_cursor.lnum = NUM2LONG(lnum); win->w_cursor.col = NUM2UINT(col); win->w_set_curswant = TRUE; - check_cursor(); /* put cursor on an existing line */ + check_cursor(); // put cursor on an existing line update_screen(NOT_VALID); return Qnil; } @@ -1739,8 +1739,8 @@ ruby_vim_init(void) objtbl = rb_hash_new(); rb_global_variable(&objtbl); - /* The Vim module used to be called "VIM", but "Vim" is better. Make an - * alias "VIM" for backwards compatibility. */ + // The Vim module used to be called "VIM", but "Vim" is better. Make an + // alias "VIM" for backwards compatibility. mVIM = rb_define_module("Vim"); rb_define_const(rb_cObject, "VIM", mVIM); rb_define_const(mVIM, "VERSION_MAJOR", INT2NUM(VIM_VERSION_MAJOR)); @@ -1775,8 +1775,8 @@ ruby_vim_init(void) rb_define_method(cBuffer, "delete", buffer_delete, 1); rb_define_method(cBuffer, "append", buffer_append, 2); - /* Added line manipulation functions - * SegPhault - 03/07/05 */ + // Added line manipulation functions + // SegPhault - 03/07/05 rb_define_method(cBuffer, "line_number", current_line_number, 0); rb_define_method(cBuffer, "line", line_s_current, 0); rb_define_method(cBuffer, "line=", set_current_line, 1); @@ -1801,7 +1801,7 @@ ruby_vim_init(void) void vim_ruby_init(void *stack_start) { - /* should get machine stack start address early in main function */ + // should get machine stack start address early in main function ruby_stack_start = stack_start; }
--- a/src/if_tcl.c +++ b/src/if_tcl.c @@ -67,10 +67,10 @@ TODO: */ #include "vim.h" -#undef EXTERN /* tcl.h defines it too */ +#undef EXTERN // tcl.h defines it too #ifdef DYNAMIC_TCL -# define USE_TCL_STUBS /* use tcl's stubs mechanism */ +# define USE_TCL_STUBS // use tcl's stubs mechanism #endif #include <tcl.h> @@ -106,7 +106,7 @@ static tcl_info tclinfo = { NULL, 0, 0, #define VIMOUT ((ClientData)1) #define VIMERR ((ClientData)2) -/* This appears to be new in Tcl 8.4. */ +// This appears to be new in Tcl 8.4. #ifndef CONST84 # define CONST84 #endif @@ -123,9 +123,9 @@ struct ref struct ref *next; Tcl_Interp *interp; - Tcl_Command cmd; /* Tcl command that represents this object */ - Tcl_Obj *delcmd; /* Tcl command to call when object is being del. */ - void *vimobj; /* Vim window or buffer (win_T* or buf_T*) */ + Tcl_Command cmd; // Tcl command that represents this object + Tcl_Obj *delcmd; // Tcl command to call when object is being del. + void *vimobj; // Vim window or buffer (win_T* or buf_T*) }; static char * tclgetbuffer _ANSI_ARGS_((Tcl_Interp *interp, buf_T *buf)); static char * tclgetwindow _ANSI_ARGS_((Tcl_Interp *interp, win_T *win)); @@ -142,11 +142,11 @@ static void tclmsg _ANSI_ARGS_((char *te static void tclerrmsg _ANSI_ARGS_((char *text)); static void tclupdatevars _ANSI_ARGS_((void)); -static struct ref refsdeleted; /* dummy object for deleted ref list */ +static struct ref refsdeleted; // dummy object for deleted ref list -/***************************************************************************** - * TCL interface manager - ****************************************************************************/ +////////////////////////////////////////////////////////////////////////////// +// TCL interface manager +//////////////////////////////////////////////////////////////////////////// #if defined(DYNAMIC_TCL) || defined(PROTO) # ifndef DYNAMIC_TCL_DLL @@ -156,7 +156,7 @@ static struct ref refsdeleted; /* dummy # define DYNAMIC_TCL_VER "8.3" # endif -# ifndef DYNAMIC_TCL /* Just generating prototypes */ +# ifndef DYNAMIC_TCL // Just generating prototypes typedef int HANDLE; # endif @@ -230,7 +230,7 @@ tcl_runtime_link_init(char *libname, int } return OK; } -#endif /* defined(DYNAMIC_TCL) || defined(PROTO) */ +#endif // defined(DYNAMIC_TCL) || defined(PROTO) #ifdef DYNAMIC_TCL static char *find_executable_arg = NULL; @@ -270,7 +270,7 @@ tcl_enabled(int verbose) Tcl_DeleteInterp(interp); stubs_initialized = TRUE; } - /* FIXME: When Tcl_InitStubs() was failed, how delete interp? */ + // FIXME: When Tcl_InitStubs() was failed, how delete interp? } } return stubs_initialized; @@ -289,9 +289,9 @@ tcl_end(void) #endif } -/**************************************************************************** - Tcl commands - ****************************************************************************/ +///////////////////////////////////////////////////////////////////////////// +// Tcl commands +//////////////////////////////////////////////////////////////////////////// /* * Replace standard "exit" command. @@ -321,7 +321,7 @@ exitcmd( case 2: if (Tcl_GetIntFromObj(interp, objv[1], &value) != TCL_OK) break; - /* FALLTHROUGH */ + // FALLTHROUGH case 1: tclinfo.exitvalue = value; @@ -402,7 +402,7 @@ buffercmd( Tcl_SetResult(interp, _("invalid buffer number"), TCL_STATIC); return TCL_ERROR; } - Tcl_ResetResult(interp); /* clear error from Tcl_GetIntFromObj */ + Tcl_ResetResult(interp); // clear error from Tcl_GetIntFromObj err = Tcl_GetIndexFromObj(interp, objv[1], bcmdoptions, "option", 0, &idx); if (err != TCL_OK) @@ -576,7 +576,7 @@ bufselfcmd( * Get line number of last line. */ opt = 1; - /* fallthrough */ + // fallthrough case BUF_COUNT: /* * Get number of lines in buffer. @@ -639,7 +639,7 @@ bufselfcmd( err = TCL_ERROR; } } - else { /* objc == 3 */ + else { // objc == 3 line = (char *)ml_get_buf(buf, (linenr_T)val1, FALSE); Tcl_SetResult(interp, line, TCL_VOLATILE); } @@ -725,7 +725,7 @@ bufselfcmd( } if (i < lc) { - /* append lines */ + // append lines do { line = Tcl_GetStringFromObj(lv[i], NULL); @@ -738,7 +738,7 @@ bufselfcmd( } else if (n <= val2) { - /* did not replace all lines, delete */ + // did not replace all lines, delete i = n; do { @@ -747,13 +747,13 @@ bufselfcmd( ++n; } while (n <= val2); } - lc -= val2 - val1 + 1; /* number of lines to be replaced */ + lc -= val2 - val1 + 1; // number of lines to be replaced mark_adjust((linenr_T)val1, (linenr_T)val2, (long)MAXLNUM, (long)lc); changed_lines((linenr_T)val1, 0, (linenr_T)val2 + 1, (long)lc); break; setListError: - u_undo(1); /* ??? */ + u_undo(1); // ??? Tcl_SetResult(interp, _("cannot set line(s)"), TCL_STATIC); err = TCL_ERROR; } @@ -838,7 +838,7 @@ bufselfcmd( case BUF_INSERT: opt = 1; - /* fallthrough */ + // fallthrough case BUF_APPEND: if (objc != 4) { @@ -1078,7 +1078,7 @@ winselfcmd( if (err != TCL_OK) break; } - else { /* objc == 4 */ + else { // objc == 4 err = tclgetlinenum(interp, objv[2], &val1, win->w_buffer); if (err != TCL_OK) break; @@ -1086,7 +1086,7 @@ winselfcmd( if (err != TCL_OK) break; } - /* TODO: should check column */ + // TODO: should check column win->w_cursor.lnum = val1; win->w_cursor.col = col2vim(val2); win->w_set_curswant = TRUE; @@ -1145,9 +1145,9 @@ exprcmd( return tclvimexpr(interp, objc, objv, 1); } -/**************************************************************************** - Support functions for Tcl commands - ****************************************************************************/ +///////////////////////////////////////////////////////////////////////////// +// Support functions for Tcl commands +//////////////////////////////////////////////////////////////////////////// /* * Get a line number from 'obj' and convert it to vim's range. @@ -1215,7 +1215,7 @@ tclfindwin(buf_T *buf) if (win->w_buffer == buf) return win; } - return curwin; /* keep current window context */ + return curwin; // keep current window context } /* @@ -1267,7 +1267,7 @@ tcldoexcommand( --emsg_off; err = vimerror(interp); - /* If the ex command created a new Tcl interpreter, remove it */ + // If the ex command created a new Tcl interpreter, remove it if (tclinfo.interp) tcldelthisinterp(); memcpy(&tclinfo, &saveinfo, sizeof(tcl_info)); @@ -1325,7 +1325,7 @@ tclsetoption( { if (isnum) { - sval = NULL; /* avoid compiler warning */ + sval = NULL; // avoid compiler warning err = Tcl_GetIndexFromObj(interp, objv[objn], optkw, "", 0, &idx); if (err != TCL_OK) { @@ -1440,11 +1440,11 @@ delref(ClientData cref) static char * tclgetref( Tcl_Interp *interp, - void **refstartP, /* ptr to w_tcl_ref/b_tcl-ref member of - win_T/buf_T struct */ - char *prefix, /* "win" or "buf" */ - void *vimobj, /* win_T* or buf_T* */ - Tcl_ObjCmdProc *proc) /* winselfcmd or bufselfcmd */ + void **refstartP, // ptr to w_tcl_ref/b_tcl-ref member of + // win_T/buf_T struct + char *prefix, // "win" or "buf" + void *vimobj, // win_T* or buf_T* + Tcl_ObjCmdProc *proc) // winselfcmd or bufselfcmd { struct ref *ref, *unused = NULL; static char name[VARNAME_SIZE]; @@ -1481,7 +1481,7 @@ tclgetref( (*refstartP) = (void *)ref; } - /* This might break on some exotic systems... */ + // This might break on some exotic systems... vim_snprintf(name, sizeof(name), "::vim::%s_%lx", prefix, (unsigned long)vimobj); cmd = Tcl_CreateObjCommand(interp, name, proc, @@ -1534,23 +1534,23 @@ tclsetdelcmd( } reflist = reflist->next; } - /* This should never happen. Famous last word? */ + // This should never happen. Famous last word? emsg(_("E280: TCL FATAL ERROR: reflist corrupt!? Please report this to vim-dev@vim.org")); Tcl_SetResult(interp, _("cannot register callback command: buffer/window reference not found"), TCL_STATIC); return TCL_ERROR; } -/******************************************* - I/O Channel -********************************************/ +//////////////////////////////////////////// +// I/O Channel +//////////////////////////////////////////// static int tcl_channel_close(ClientData instance, Tcl_Interp *interp UNUSED) { int err = 0; - /* currently does nothing */ + // currently does nothing if (instance != VIMOUT && instance != VIMERR) { @@ -1568,7 +1568,7 @@ tcl_channel_input( int *errptr) { - /* input is currently not supported */ + // input is currently not supported Tcl_SetErrno(EINVAL); if (errptr) @@ -1586,10 +1586,9 @@ tcl_channel_output( char_u *str; int result; - /* The buffer is not guaranteed to be 0-terminated, and we don't if - * there is enough room to add a '\0'. So we have to create a copy - * of the buffer... - */ + // The buffer is not guaranteed to be 0-terminated, and we don't if + // there is enough room to add a '\0'. So we have to create a copy + // of the buffer... str = vim_strnsave((char_u *)buf, bufsiz); if (!str) { @@ -1635,43 +1634,43 @@ tcl_channel_gethandle( static Tcl_ChannelType tcl_channel_type = { - "vimmessage", /* typeName */ - TCL_CHANNEL_VERSION_2, /* version */ - tcl_channel_close, /* closeProc */ - tcl_channel_input, /* inputProc */ - tcl_channel_output, /* outputProc */ - NULL, /* seekProc */ - NULL, /* setOptionProc */ - NULL, /* getOptionProc */ - tcl_channel_watch, /* watchProc */ - tcl_channel_gethandle, /* getHandleProc */ - NULL, /* close2Proc */ - NULL, /* blockModeProc */ + "vimmessage", // typeName + TCL_CHANNEL_VERSION_2, // version + tcl_channel_close, // closeProc + tcl_channel_input, // inputProc + tcl_channel_output, // outputProc + NULL, // seekProc + NULL, // setOptionProc + NULL, // getOptionProc + tcl_channel_watch, // watchProc + tcl_channel_gethandle, // getHandleProc + NULL, // close2Proc + NULL, // blockModeProc #ifdef TCL_CHANNEL_VERSION_2 - NULL, /* flushProc */ - NULL, /* handlerProc */ + NULL, // flushProc + NULL, // handlerProc #endif -/* The following should not be necessary since TCL_CHANNEL_VERSION_2 was - * set above */ +// The following should not be necessary since TCL_CHANNEL_VERSION_2 was +// set above #ifdef TCL_CHANNEL_VERSION_3 - NULL, /* wideSeekProc */ + NULL, // wideSeekProc #endif #ifdef TCL_CHANNEL_VERSION_4 - NULL, /* threadActionProc */ + NULL, // threadActionProc #endif #ifdef TCL_CHANNEL_VERSION_5 - NULL /* truncateProc */ + NULL // truncateProc #endif }; -/********************************** - Interface to vim - **********************************/ +/////////////////////////////////// +// Interface to vim +////////////////////////////////// static void tclupdatevars(void) { - char varname[VARNAME_SIZE]; /* must be writeable */ + char varname[VARNAME_SIZE]; // must be writeable char *name; strcpy(varname, VAR_RANGE1); @@ -1699,7 +1698,7 @@ tclupdatevars(void) static int tclinit(exarg_T *eap) { - char varname[VARNAME_SIZE]; /* Tcl_LinkVar requires writeable varname */ + char varname[VARNAME_SIZE]; // Tcl_LinkVar requires writeable varname char *name; #ifdef DYNAMIC_TCL @@ -1715,9 +1714,9 @@ tclinit(exarg_T *eap) Tcl_Interp *interp; static Tcl_Channel ch1, ch2; - /* Create replacement channels for stdout and stderr; this has to be - * done each time an interpreter is created since the channels are closed - * when the interpreter is deleted */ + // Create replacement channels for stdout and stderr; this has to be + // done each time an interpreter is created since the channels are closed + // when the interpreter is deleted ch1 = Tcl_CreateChannel(&tcl_channel_type, "vimout", VIMOUT, TCL_WRITABLE); ch2 = Tcl_CreateChannel(&tcl_channel_type, "vimerr", VIMERR, TCL_WRITABLE); Tcl_SetStdChannel(ch1, TCL_STDOUT); @@ -1732,7 +1731,7 @@ tclinit(exarg_T *eap) return FAIL; } #if 0 - /* VIM sure is interactive */ + // VIM sure is interactive Tcl_SetVar(interp, "tcl_interactive", "1", TCL_GLOBAL_ONLY); #endif @@ -1745,12 +1744,12 @@ tclinit(exarg_T *eap) Tcl_SetChannelOption(interp, ch2, "-translation", "lf"); #endif - /* replace standard Tcl exit command */ + // replace standard Tcl exit command Tcl_DeleteCommand(interp, "exit"); Tcl_CreateObjCommand(interp, "exit", exitcmd, (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - /* new commands, in ::vim namespace */ + // new commands, in ::vim namespace Tcl_CreateObjCommand(interp, "::vim::buffer", buffercmd, (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); Tcl_CreateObjCommand(interp, "::vim::window", windowcmd, @@ -1764,12 +1763,12 @@ tclinit(exarg_T *eap) Tcl_CreateObjCommand(interp, "::vim::expr", exprcmd, (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); - /* "lbase" variable */ + // "lbase" variable tclinfo.lbase = 1; strcpy(varname, VAR_LBASE); Tcl_LinkVar(interp, varname, (char *)&tclinfo.lbase, TCL_LINK_INT); - /* "range" variable */ + // "range" variable tclinfo.range_start = eap->line1; strcpy(varname, VAR_RANGE1); Tcl_LinkVar(interp, varname, (char *)&tclinfo.range_start, TCL_LINK_INT|TCL_LINK_READ_ONLY); @@ -1779,7 +1778,7 @@ tclinit(exarg_T *eap) strcpy(varname, VAR_RANGE3); Tcl_LinkVar(interp, varname, (char *)&tclinfo.range_end, TCL_LINK_INT|TCL_LINK_READ_ONLY); - /* "current" variable */ + // "current" variable tclinfo.curbuf = Tcl_Alloc(VARNAME_SIZE); tclinfo.curwin = Tcl_Alloc(VARNAME_SIZE); name = tclgetbuffer(interp, curbuf); @@ -1795,7 +1794,7 @@ tclinit(exarg_T *eap) } else { - /* Interpreter already exists, just update variables */ + // Interpreter already exists, just update variables tclinfo.range_start = row2tcl(eap->line1); tclinfo.range_end = row2tcl(eap->line2); tclupdatevars(); @@ -1841,15 +1840,14 @@ tcldelthisinterp(void) if (!Tcl_InterpDeleted(tclinfo.interp)) Tcl_DeleteInterp(tclinfo.interp); Tcl_Release(tclinfo.interp); - /* The interpreter is now gets deleted. All registered commands (esp. - * window and buffer commands) are deleted, triggering their deletion - * callback, which deletes all refs pointing to this interpreter. - * We could garbage-collect the unused ref structs in all windows and - * buffers, but unless the user creates hundreds of sub-interpreters - * all referring to lots of windows and buffers, this is hardly worth - * the effort. Unused refs are recycled by other interpreters, and - * all refs are free'd when the window/buffer gets closed by vim. - */ + // The interpreter is now gets deleted. All registered commands (esp. + // window and buffer commands) are deleted, triggering their deletion + // callback, which deletes all refs pointing to this interpreter. + // We could garbage-collect the unused ref structs in all windows and + // buffers, but unless the user creates hundreds of sub-interpreters + // all referring to lots of windows and buffers, this is hardly worth + // the effort. Unused refs are recycled by other interpreters, and + // all refs are free'd when the window/buffer gets closed by vim. tclinfo.interp = NULL; Tcl_Free(tclinfo.curbuf); @@ -1862,9 +1860,9 @@ tclexit(int error) { int newerr = OK; - if (Tcl_InterpDeleted(tclinfo.interp) /* True if we intercepted Tcl's exit command */ + if (Tcl_InterpDeleted(tclinfo.interp) // True if we intercepted Tcl's exit command #if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 5) || TCL_MAJOR_VERSION > 8 - || Tcl_LimitExceeded(tclinfo.interp) /* True if the interpreter cannot continue */ + || Tcl_LimitExceeded(tclinfo.interp) // True if the interpreter cannot continue #endif ) { @@ -1954,7 +1952,7 @@ ex_tcldo(exarg_T *eap) { char *script, *line; int err, rs, re, lnum; - char var_lnum[VARNAME_SIZE]; /* must be writeable memory */ + char var_lnum[VARNAME_SIZE]; // must be writeable memory char var_line[VARNAME_SIZE]; linenr_T first_line = 0; linenr_T last_line = 0; @@ -2035,7 +2033,7 @@ tcldelallrefs(struct ref *ref) char *result; #ifdef DYNAMIC_TCL - /* TODO: this code currently crashes Vim on exit */ + // TODO: this code currently crashes Vim on exit if (exiting) return; #endif @@ -2070,7 +2068,7 @@ tcl_buffer_free(buf_T *buf) struct ref *reflist; #ifdef DYNAMIC_TCL - if (!stubs_initialized) /* Not using Tcl, nothing to do. */ + if (!stubs_initialized) // Not using Tcl, nothing to do. return; #endif @@ -2089,7 +2087,7 @@ tcl_window_free(win_T *win) struct ref *reflist; #ifdef DYNAMIC_TCL - if (!stubs_initialized) /* Not using Tcl, nothing to do. */ + if (!stubs_initialized) // Not using Tcl, nothing to do. return; #endif @@ -2102,4 +2100,4 @@ tcl_window_free(win_T *win) } } -/* The End */ +// The End
--- a/src/if_xcmdsrv.c +++ b/src/if_xcmdsrv.c @@ -64,18 +64,18 @@ typedef struct PendingCommand { - int serial; /* Serial number expected in result. */ - int code; /* Result Code. 0 is OK */ - char_u *result; /* String result for command (malloc'ed). - * NULL means command still pending. */ + int serial; // Serial number expected in result. + int code; // Result Code. 0 is OK + char_u *result; // String result for command (malloc'ed). + // NULL means command still pending. struct PendingCommand *nextPtr; - /* Next in list of all outstanding commands. - * NULL means end of list. */ + // Next in list of all outstanding commands. + // NULL means end of list. } PendingCommand; static PendingCommand *pendingCommands = NULL; - /* List of all commands currently - * being waited for. */ + // List of all commands currently + // being waited for. /* * The information below is used for communication between processes @@ -179,7 +179,7 @@ struct x_cmdqueue typedef struct x_cmdqueue x_queue_T; -/* dummy node, header for circular queue */ +// dummy node, header for circular queue static x_queue_T head = {NULL, 0, NULL, NULL}; /* @@ -200,12 +200,12 @@ static int IsSerialName(char_u *name); static void save_in_queue(char_u *buf, long_u len); static void server_parse_message(Display *dpy, char_u *propInfo, long_u numItems); -/* Private variables for the "server" functionality */ +// Private variables for the "server" functionality static Atom registryProperty = None; static Atom vimProperty = None; static int got_x_error = FALSE; -static char_u *empty_prop = (char_u *)""; /* empty GetRegProp() result */ +static char_u *empty_prop = (char_u *)""; // empty GetRegProp() result /* * Associate an ASCII name with Vim. Try real hard to get a unique one. @@ -213,8 +213,8 @@ static char_u *empty_prop = (char_u *)"" */ int serverRegisterName( - Display *dpy, /* display to register with */ - char_u *name) /* the name that will be used as a base */ + Display *dpy, // display to register with + char_u *name) // the name that will be used as a base { int i; int res; @@ -329,25 +329,25 @@ DoRegisterName(Display *dpy, char_u *nam */ void serverChangeRegisteredWindow( - Display *dpy, /* Display to register with */ - Window newwin) /* Re-register to this ID */ + Display *dpy, // Display to register with + Window newwin) // Re-register to this ID { char_u propInfo[MAX_NAME_LENGTH + 20]; commWindow = newwin; - /* Always call SendInit() here, to make sure commWindow is marked as a Vim - * window. */ + // Always call SendInit() here, to make sure commWindow is marked as a Vim + // window. if (SendInit(dpy) < 0) return; - /* WARNING: Do not step through this while debugging, it will hangup the X - * server! */ + // WARNING: Do not step through this while debugging, it will hangup the X + // server! XGrabServer(dpy); DeleteAnyLingerer(dpy, newwin); if (serverName != NULL) { - /* Reinsert name if we was already registered */ + // Reinsert name if we was already registered (void)LookupName(dpy, serverName, /*delete=*/TRUE, NULL); sprintf((char *)propInfo, "%x %.*s", (int_u)newwin, MAX_NAME_LENGTH, serverName); @@ -365,30 +365,30 @@ serverChangeRegisteredWindow( */ int serverSendToVim( - Display *dpy, /* Where to send. */ - char_u *name, /* Where to send. */ - char_u *cmd, /* What to send. */ - char_u **result, /* Result of eval'ed expression */ - Window *server, /* Actual ID of receiving app */ - Bool asExpr, /* Interpret as keystrokes or expr ? */ - int timeout, /* seconds to wait or zero */ - Bool localLoop, /* Throw away everything but result */ - int silent) /* don't complain about no server */ + Display *dpy, // Where to send. + char_u *name, // Where to send. + char_u *cmd, // What to send. + char_u **result, // Result of eval'ed expression + Window *server, // Actual ID of receiving app + Bool asExpr, // Interpret as keystrokes or expr ? + int timeout, // seconds to wait or zero + Bool localLoop, // Throw away everything but result + int silent) // don't complain about no server { Window w; char_u *property; int length; int res; - static int serial = 0; /* Running count of sent commands. - * Used to give each command a - * different serial number. */ + static int serial = 0; // Running count of sent commands. + // Used to give each command a + // different serial number. PendingCommand pending; char_u *loosename = NULL; if (result != NULL) *result = NULL; if (name == NULL || *name == NUL) - name = (char_u *)"GVIM"; /* use a default name */ + name = (char_u *)"GVIM"; // use a default name if (commProperty == None && dpy != NULL) { @@ -396,7 +396,7 @@ serverSendToVim( return -1; } - /* Execute locally if no display or target is ourselves */ + // Execute locally if no display or target is ourselves if (dpy == NULL || (serverName != NULL && STRICMP(name, serverName) == 0)) return sendToLocalVim(cmd, asExpr, result); @@ -411,7 +411,7 @@ serverSendToVim( while (TRUE) { w = LookupName(dpy, name, FALSE, &loosename); - /* Check that the window is hot */ + // Check that the window is hot if (w != None) { if (!WindowValid(dpy, w)) @@ -447,11 +447,11 @@ serverSendToVim( 0, asExpr ? 'c' : 'k', 0, name, 0, p_enc, 0, cmd); if (name == loosename) vim_free(loosename); - /* Add a back reference to our comm window */ + // Add a back reference to our comm window serial++; sprintf((char *)property + length, "%c-r %x %d", 0, (int_u)commWindow, serial); - /* Add length of what "-r %x %d" resulted in, skipping the NUL. */ + // Add length of what "-r %x %d" resulted in, skipping the NUL. length += STRLEN(property + length + 1) + 1; res = AppendPropCarefully(dpy, w, commProperty, property, length + 1); @@ -462,7 +462,7 @@ serverSendToVim( return -1; } - if (!asExpr) /* There is no answer for this - Keys are sent async */ + if (!asExpr) // There is no answer for this - Keys are sent async return 0; /* @@ -592,7 +592,7 @@ ServerWait( check_due_timer(); #endif - /* Just look out for the answer without calling back into Vim */ + // Just look out for the answer without calling back into Vim if (localLoop) { #ifndef HAVE_SELECT @@ -670,9 +670,8 @@ serverGetVimNames(Display *dpy) return ga.ga_data; } -/* ---------------------------------------------------------- - * Reply stuff - */ +///////////////////////////////////////////////////////////// +// Reply stuff static struct ServerReply * ServerReplyFind(Window w, enum ServerReplyOp op) @@ -754,7 +753,7 @@ serverSendReply(char_u *name, char_u *st { sprintf((char *)property, "%cn%c-E %s%c-n %s%c-w %x", 0, 0, p_enc, 0, str, 0, (unsigned int)commWindow); - /* Add length of what "%x" resulted in. */ + // Add length of what "%x" resulted in. length += STRLEN(property + length); res = AppendPropCarefully(dpy, win, commProperty, property, length + 1); vim_free(property); @@ -804,7 +803,7 @@ serverReadReply( } else { - /* Last string read. Remove from list */ + // Last string read. Remove from list ga_clear(&p->strings); ServerReplyFind(win, SROP_Delete); } @@ -864,14 +863,14 @@ SendInit(Display *dpy) WhitePixel(dpy, DefaultScreen(dpy)), WhitePixel(dpy, DefaultScreen(dpy))); XSelectInput(dpy, commWindow, PropertyChangeMask); - /* WARNING: Do not step through this while debugging, it will hangup - * the X server! */ + // WARNING: Do not step through this while debugging, it will hangup + // the X server! XGrabServer(dpy); DeleteAnyLingerer(dpy, commWindow); XUngrabServer(dpy); } - /* Make window recognizable as a vim window */ + // Make window recognizable as a vim window XChangeProperty(dpy, commWindow, vimProperty, XA_STRING, 8, PropModeReplace, (char_u *)VIM_VERSION_SHORT, (int)STRLEN(VIM_VERSION_SHORT) + 1); @@ -896,11 +895,11 @@ SendInit(Display *dpy) */ static Window LookupName( - Display *dpy, /* Display whose registry to check. */ - char_u *name, /* Name of a server. */ - int delete, /* If non-zero, delete info about name. */ - char_u **loose) /* Do another search matching -999 if not found - Return result here if a match is found */ + Display *dpy, // Display whose registry to check. + char_u *name, // Name of a server. + int delete, // If non-zero, delete info about name. + char_u **loose) // Do another search matching -999 if not found + // Return result here if a match is found { char_u *regProp, *entry; char_u *p; @@ -917,7 +916,7 @@ LookupName( * Scan the property for the desired name. */ returnValue = (int_u)None; - entry = NULL; /* Not needed, but eliminates compiler warning. */ + entry = NULL; // Not needed, but eliminates compiler warning. for (p = regProp; (long_u)(p - regProp) < numItems; ) { entry = p; @@ -990,8 +989,8 @@ LookupName( */ static void DeleteAnyLingerer( - Display *dpy, /* Display whose registry to check. */ - Window win) /* Window to remove */ + Display *dpy, // Display whose registry to check. + Window win) // Window to remove { char_u *regProp, *entry = NULL; char_u *p; @@ -1004,7 +1003,7 @@ DeleteAnyLingerer( if (GetRegProp(dpy, ®Prop, &numItems, FALSE) == FAIL) return; - /* Scan the property for the window id. */ + // Scan the property for the window id. for (p = regProp; (long_u)(p - regProp) < numItems; ) { if (*p != 0) @@ -1014,7 +1013,7 @@ DeleteAnyLingerer( { int lastHalf; - /* Copy down the remainder to delete entry */ + // Copy down the remainder to delete entry entry = p; while (*p != 0) p++; @@ -1055,7 +1054,7 @@ GetRegProp( Display *dpy, char_u **regPropp, long_u *numItemsp, - int domsg) /* When TRUE give error message. */ + int domsg) // When TRUE give error message. { int result, actualFormat; long_u bytesAfter; @@ -1079,13 +1078,13 @@ GetRegProp( if (actualType == None) { - /* No prop yet. Logically equal to the empty list */ + // No prop yet. Logically equal to the empty list *numItemsp = 0; *regPropp = empty_prop; return OK; } - /* If the property is improperly formed, then delete it. */ + // If the property is improperly formed, then delete it. if (result != Success || actualFormat != 8 || actualType != XA_STRING) { if (*regPropp != NULL) @@ -1110,8 +1109,8 @@ GetRegProp( void serverEventProc( Display *dpy, - XEvent *eventPtr, /* Information about event. */ - int immediate) /* Run event immediately. Should mostly be 0. */ + XEvent *eventPtr, // Information about event. + int immediate) // Run event immediately. Should mostly be 0. { char_u *propInfo; int result, actualFormat; @@ -1135,7 +1134,7 @@ serverEventProc( &actualFormat, &numItems, &bytesAfter, &propInfo); - /* If the property doesn't exist or is improperly formed then ignore it. */ + // If the property doesn't exist or is improperly formed then ignore it. if (result != Success || actualType != XA_STRING || actualFormat != 8) { if (propInfo != NULL) @@ -1159,17 +1158,17 @@ save_in_queue(char_u *propInfo, long_u l node = ALLOC_ONE(x_queue_T); if (node == NULL) - return; /* out of memory */ + return; // out of memory node->propInfo = propInfo; node->len = len; - if (head.next == NULL) /* initialize circular queue */ + if (head.next == NULL) // initialize circular queue { head.next = &head; head.prev = &head; } - /* insert node at tail of queue */ + // insert node at tail of queue node->next = &head; node->prev = head.prev; head.prev->next = node; @@ -1185,7 +1184,7 @@ server_parse_messages(void) x_queue_T *node; if (!X_DISPLAY) - return; /* cannot happen? */ + return; // cannot happen? while (head.next != NULL && head.next != &head) { node = head.next; @@ -1214,8 +1213,8 @@ server_waiting(void) static void server_parse_message( Display *dpy, - char_u *propInfo, /* A string containing 0 or more X commands */ - long_u numItems) /* The size of propInfo in bytes. */ + char_u *propInfo, // A string containing 0 or more X commands + long_u numItems) // The size of propInfo in bytes. { char_u *p; int code; @@ -1276,7 +1275,7 @@ server_parse_message( else { p = serial = end + 1; - clientWindow = resWindow; /* Remember in global */ + clientWindow = resWindow; // Remember in global } break; case 'n': @@ -1314,14 +1313,14 @@ server_parse_message( { garray_T reply; - /* Initialize the result property. */ + // Initialize the result property. ga_init2(&reply, 1, 100); (void)ga_grow(&reply, 50 + STRLEN(p_enc)); sprintf(reply.ga_data, "%cr%c-E %s%c-s %s%c-r ", 0, 0, p_enc, 0, serial, 0); reply.ga_len = 14 + STRLEN(p_enc) + STRLEN(serial); - /* Evaluate the expression and return the result. */ + // Evaluate the expression and return the result. if (res != NULL) ga_concat(&reply, res); else @@ -1485,11 +1484,11 @@ server_parse_message( */ static int AppendPropCarefully( - Display *dpy, /* Display on which to operate. */ - Window window, /* Window whose property is to be modified. */ - Atom property, /* Name of property. */ - char_u *value, /* Characters to append to property. */ - int length) /* How much to append */ + Display *dpy, // Display on which to operate. + Window window, // Window whose property is to be modified. + Atom property, // Name of property. + char_u *value, // Characters to append to property. + int length) // How much to append { XErrorHandler old_handler; @@ -1524,4 +1523,4 @@ IsSerialName(char_u *str) return (len > 1 && vim_isdigit(str[len - 1])); } -#endif /* FEAT_CLIENTSERVER */ +#endif // FEAT_CLIENTSERVER