home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / wp_dtp / xdme1821.lha / XDME / smallspc.c < prev    next >
C/C++ Source or Header  |  1993-03-30  |  17KB  |  812 lines

  1. /******************************************************************************
  2.  
  3.     MODUL
  4.     smallspc.c
  5.  
  6.     DESCRIPTION
  7.     minimal interface for special variables
  8.     setting and reading
  9.  
  10.     NOTES
  11.     look into future/...
  12.  
  13.     BUGS
  14.     none known
  15.  
  16.     TODO
  17.     entries for all new spcvars
  18.     join the 3 functions into 1
  19.     create a list that is scanned in a loop
  20.  
  21.     EXAMPLES
  22.  
  23.     SEE ALSO
  24.     vars.c
  25.  
  26.     INDEX
  27.  
  28.     HISTORY
  29.     21 Nov 92 null created
  30.  
  31. ******************************************************************************/
  32.  
  33. /**************************************
  34.         Includes
  35. **************************************/
  36. #include "defs.h"
  37.  
  38. /**************************************
  39.         Globale Variable
  40. **************************************/
  41. Prototype char* GetSpecialVar (char* Name);
  42. Prototype char* GetSpecialInt (char* Name);
  43. Prototype char* GetSpecialFlag(char* Name);
  44.  
  45. Prototype char SetSpecialFlag(char* Name, char* Value);
  46. Prototype char SetSpecialInt (char* Name, char* Value);
  47. Prototype char SetSpecialVar (char* Name, char* Value);
  48.  
  49. Prototype void do_togglespecialflag(void);
  50. Prototype void do_setspecialvar(void);
  51.  
  52. extern UBYTE Fstr[];
  53. extern UBYTE Rstr[];
  54.  
  55. /**************************************
  56.       Interne Defines & Strukturen
  57. **************************************/
  58.     const char* N_ascii     = "ascii";
  59.     const char* N_autoindent    = "autoindent";
  60.     const char* N_autosplit    = "autosplit";
  61.     const char* N_autounblock    = "autounblock";
  62.     const char* N_activetofront = "activetofront";
  63.     const char* N_bgpen     = "bgpen";
  64.     const char* N_bbpen     = "bbpen";
  65.     const char* N_colno     = "colno";
  66.     const char* N_currentline    = "currentline";
  67.     const char* N_currentword    = "currentword";
  68.     const char* N_cursorpen    = "cursorpen";
  69.     const char* N_debug     = "debug";
  70.     const char* N_fgpen     = "fgpen";
  71.     const char* N_filename    = "filename";
  72.     const char* N_findstr    = "findstr";
  73.     const char* N_fname     = "fname";
  74.     const char* N_fpath     = "fpath";
  75.     const char* N_globalsearch    = "globalsearch";
  76.     const char* N_hgpen     = "hgpen";
  77.     const char* N_ignorecase    = "ignorecase";
  78.     const char* N_infixmode    = "infixmode";
  79.     const char* N_insertmode    = "insertmode";
  80.     const char* N_keytable    = "keytable";
  81.     const char* N_lineno    = "lineno";
  82.     const char* N_margin    = "margin";
  83.     const char* N_menustrip    = "menustrip";
  84.     const char* N_modified    = "modified";
  85.     const char* N_parcol    = "parcol";
  86.     const char* N_qualifiers    = "qualifiers";
  87.     const char* N_refpaths    = "refpaths";
  88.     const char* N_repstr    = "repstr";
  89.     const char* N_restofline    = "restofline";
  90.     const char* N_rexxport    = "rexxport";
  91.     const char* N_savetabs    = "savetabs";
  92.     const char* N_scanf     = "scanf";
  93.     const char* N_tabstop    = "tabstop";
  94.     const char* N_textnames    = "textnames";
  95.     const char* N_tpen        = "tpen";
  96.     const char* N_viewmode    = "viewmode";
  97.     const char* N_wordwrap    = "wordwrap";
  98.     const char* N_windowcycling = "windowcycling";
  99.  
  100.  
  101. /**************************************
  102.         Interne Variable
  103. **************************************/
  104.  
  105.  
  106. /**************************************
  107.        Interne Prototypes
  108. **************************************/
  109. Prototype char* current_word (void);
  110.  
  111.  
  112. /*
  113. **  GetSpecialVar - Get one of the internal special String Vars:
  114. **
  115. **  >name == the name of the variable to search for
  116. **  <ptr to malloced string
  117. **  <NULL == not found or error
  118. */
  119.  
  120. char*
  121. GetSpecialVar(char* Name)
  122. {
  123.     int i,j;
  124.     char* str;        /* return */
  125.     char* ptr;        /* help: if not NULL, anything was found */
  126.  
  127.     str = NULL;
  128.     ptr = NULL;
  129.     i = 0;
  130.     j = 0;
  131. /* printf("Vn=%s\n",Name); */
  132.  
  133.     if ((Name == NULL) || (Name[0] == 0))
  134.     {
  135.     return(NULL);
  136.     } /* if */
  137.                     /* String Variables */
  138.  
  139.     switch (Name[0])
  140.     {
  141.     case 'c':
  142.     if (strcmp (Name, N_currentline) == 0)
  143.     { /* old */
  144.         ptr = Current;
  145.     } else
  146.     if (strcmp (Name, N_currentword) == 0)
  147.     { /* new */
  148.         ptr = current_word();
  149.     } /* if */
  150.     break;
  151.     case 'f':
  152.     if (strcmp (Name, N_filename) == 0)
  153.     {    /* old */
  154.         ptr = Ep->name;
  155.     } else
  156.     if (strcmp (Name, N_fname) == 0)
  157.     {    /* old */
  158.         ptr = fname(Ep->name);
  159.     } else
  160.     if (strcmp (Name, N_findstr) == 0)
  161.     {     /* old */
  162.         ptr = Fstr;
  163.     } /* if */
  164.     break;
  165.  
  166.     case 'k':                                   /* PATCH_NULL [01 Feb 1993] : added */
  167.     if (strcmp (Name, N_keytable) == 0)
  168.     {
  169.         if (ptr = currenthash()) {
  170.         ptr = ((struct Node *)ptr)->ln_Name;
  171.         } /* if */
  172.     } /* if */
  173.     break;
  174.     case 'm':                                   /* PATCH_NULL [01 Feb 1993] : added */
  175.     if (strcmp (Name, N_menustrip) == 0)
  176.     {
  177.         if (ptr = currentmenu()) {
  178.         ptr = ((struct Node *)ptr)->ln_Name;
  179.         } /* if */
  180.     } /* if */
  181.     break;
  182.     case 'r':
  183.     if (strcmp (Name, N_repstr) == 0)
  184.     {      /* old */
  185.         ptr = Rstr;
  186.     } else
  187.     if (strcmp (Name, N_restofline) == 0)
  188.     {
  189.         if (Clen>=Ep->column) {
  190.         ptr = Current + Ep->column;        /* DANGER */
  191.         } else {
  192.         ptr = Current + Clen;
  193.         } /* if */
  194.     } /* if */
  195.     break;
  196.     case 's':
  197.     if (strcmp (Name, N_scanf) == 0)
  198.     {    /* old */
  199.         ptr = String;
  200.     } /* if */
  201.     break;
  202.     default:
  203.     break;
  204.     } /* switch */
  205.  
  206.     if (ptr != NULL)
  207.     {
  208.     str = malloc (strlen(ptr)+1);
  209.     if (str)
  210.     {
  211.         strcpy(str, ptr);
  212.         return(str);
  213.     } else if (*ptr != 0)
  214.     {
  215.         nomemory();
  216.         abort(NULL);
  217.     } else
  218.     {
  219.         return(str);
  220.     } /* if */
  221.     } /* if */
  222.  
  223.     return(NULL);
  224. } /* GetSpcVar */
  225.  
  226.  
  227. /*
  228. **  SetSpecialVar - set one of DME's internal special String vars
  229. **
  230. **  >Name  - name of the variable to modify
  231. **  >Value - new value of the variable
  232. **  <0 == name not found
  233. **  <1 == ok ( also if variable is readonly )
  234. */
  235.  
  236. char
  237. SetSpecialVar(char* Name, char* Value)
  238. {
  239.     char* ptr;
  240.     int len;
  241.  
  242.     if ((Name == NULL) || (Name[0] == 0))
  243.     {
  244.     return(0);
  245.     } /* if */
  246.     ptr = NULL;
  247.     len = LINE_LENGTH;
  248.  
  249. /* printf("Vs=%s\n",Name); */
  250.  
  251.     if (strcmp (Name, N_filename) == 0)
  252.     {
  253.         ptr = Ep->name;
  254.         len = 63;
  255.     } else
  256.  
  257.     if (strcmp (Name, N_findstr) == 0)
  258.     {
  259.         ptr = Fstr;
  260.     } else
  261.     if (strcmp (Name, N_repstr) == 0)
  262.     {
  263.         ptr = Rstr;
  264.     } else
  265.     if (strcmp (Name, N_scanf) == 0)
  266.     {
  267.         ptr = String;
  268.     } else
  269.     if (strcmp (Name, N_currentline) == 0)
  270.     {
  271.         abort(1);
  272.     } else
  273.     if (strcmp (Name, N_currentword) == 0)
  274.     {
  275.         abort(1);
  276.     } else
  277.     if (strcmp (Name, N_restofline) == 0)
  278.     {
  279.         abort(1);
  280.     } /* if */
  281.  
  282.     if (ptr)
  283.     {
  284.     strncpy(ptr, Value, len);
  285.     return(1);  /* found */
  286.     } else
  287.     return(0);  /* not found */
  288. } /* SetSpecialVar */
  289.  
  290.  
  291.  
  292. /*
  293. **  GetSpecialInt - Get one of the internal special Integer Vars:
  294. **
  295. **  >name == the name of the variable to search for
  296. **  <ptr to malloced string
  297. **  <NULL == not found or error
  298. */
  299.  
  300. char*
  301. GetSpecialInt(char* Name)
  302. {
  303.     int found;
  304.     long i;
  305.     char* str;        /* return */
  306.     char buffer[16];    /* help: convert numbers here */
  307.  
  308.     found = 0;
  309. /* printf("In=%s\n",Name); */
  310.  
  311.     if (strcmp (Name, N_ascii) == 0)
  312.     { /* current char */
  313.         i = Current[Ep->column];
  314.         found = 1;
  315.     } else
  316.     if (strcmp (Name, N_bbpen) == 0)
  317.     { /* highlight pen */
  318.         i = BLOCK_BPEN;
  319.         found = 1;
  320.     } else
  321.     if (strcmp (Name, N_bgpen) == 0)
  322.     { /* background pen */
  323.         i = TEXT_BPEN;
  324.         found = 1;
  325.     } else
  326.     if (strcmp (Name, N_colno) == 0)
  327.     { /* current xpos */
  328.         i = Ep->column + 1;
  329.         found = 1;
  330.     } else
  331.     if (strcmp (Name, N_fgpen) == 0)
  332.     { /* foreground pen */
  333.         i = TEXT_FPEN;
  334.         found = 1;
  335.     } else
  336.     if (strcmp (Name, N_hgpen) == 0)
  337.     { /* highlight pen */
  338.         i = BLOCK_FPEN;
  339.         found = 1;
  340.     } else
  341.     if (strcmp (Name, N_lineno) == 0)
  342.     { /* current ypos */
  343.         i =  Ep->line + 1;
  344.         found = 1;
  345.     } else
  346.     if (strcmp (Name, N_margin) == 0)
  347.     { /* right margin for wordwrap */
  348.         i = Ep->config.margin;
  349.         found = 1;
  350.     } else
  351.     if (strcmp (Name, N_parcol) == 0)
  352.     { /* left margin of paragraph? */
  353.         i = Ep->config.wwcol;
  354.         found = 1;
  355.     } else
  356.     if (strcmp (Name, N_tpen) == 0)
  357.     { /* title bar rendering */
  358.         i = TITLE_BPEN;
  359.         found = 1;
  360.     } else
  361.     if (strcmp (Name, N_tabstop) == 0)
  362.     {
  363.         i = Ep->config.tabstop;
  364.         found = 1;
  365.     } /* if */
  366.  
  367.  
  368.     if (found)
  369.     {
  370.     sprintf(buffer,"%ld",i);
  371.     str = malloc(strlen(buffer)+1);
  372.     if (str)
  373.     {
  374.         strcpy(str, buffer);
  375.         return(str);
  376.     } else
  377.     {
  378.         nomemory();
  379.         abort(NULL);
  380.     } /* if */
  381.     } /* if */
  382.     return(NULL);
  383. } /* GetSpecialInt */
  384.  
  385.  
  386.  
  387. /*
  388.  *  GetSpecialFlag - Get one of the internal special Flags:
  389.  *
  390.  *  >name == the name of the variable to search for
  391.  *  <ptr to malloced string
  392.  *  <NULL == not found or error
  393.  */
  394.  
  395. char*
  396. GetSpecialFlag(char* Name)
  397. {
  398.     char i,found;
  399.     char* str;        /* return */
  400.     char buffer[4];    /* help: convert numbers here */
  401.  
  402. /* printf("Fn=%s\n",Name); */
  403.     found = 0;
  404.                             /* locals */
  405.     if (strcmp (Name, N_autounblock) == 0)
  406.     {
  407.         i = Ep->config.autounblock ? 1 : 0;
  408.         found = 1;
  409.     } else
  410.     if (strcmp (Name, N_autoindent) == 0)
  411.     {
  412.         i = Ep->config.autoindent ? 1 : 0;
  413.         found = 1;
  414.     } else
  415.     if (strcmp (Name, N_autosplit) == 0)
  416.     {
  417.         i = Ep->config.autosplit ? 1 : 0;
  418.         found = 1;
  419.     } else
  420.     if (strcmp (Name, N_debug) == 0)
  421.     {
  422.         i = globalflags.debug ? 1 : 0;
  423.         found = 1;
  424.     } else
  425.     if (strcmp (Name, N_infixmode) == 0)
  426.     {  /* while searching */
  427.         i = Ep->config.ignorecase ? 1 : 0;
  428.         found = 1;
  429.     } else
  430.     if (strcmp (Name, N_insertmode) == 0)
  431.     {  /* <-> overwrite */
  432.         i = Ep->config.insertmode ? 1 : 0;
  433.         found = 1;
  434.     } else
  435.     if (strcmp (Name, N_modified) == 0)
  436.     {    /*  */
  437.         i = Ep->modified ? 1 : 0;
  438.         found = 1;
  439.     } else
  440.     if (strcmp (Name, N_viewmode) == 0)
  441.     {
  442.         i = Ep->viewmode ? 1 : 0;
  443.         found = 1;
  444.     } else
  445.     if (strcmp (Name, N_wordwrap) == 0)
  446.     {
  447.         i = Ep->config.wordwrap ? 1 : 0;
  448.         found = 1;
  449.     } else
  450.  
  451.                             /* globals */
  452.     if (strcmp (Name, N_activetofront) == 0)
  453.     {
  454.         i = globalflags.ActivateToFront ? 1 : 0;
  455.         found = 1;
  456.     } else
  457.     if (strcmp (Name, N_globalsearch) == 0)
  458.     {
  459.         i = globalflags.global_search ? 1 : 0;
  460.         found = 1;
  461.     } else
  462.     if (strcmp (Name, N_infixmode) == 0)
  463.     {   /* <-> prefixmode / math2 */
  464.         i = MathInfix ? 1 : 0;
  465.         found = 1;
  466.     } else
  467.     if (strcmp (Name, N_savetabs) == 0)
  468.     {
  469.         i = globalflags.Savetabs ? 1 : 0;
  470.         found = 1;
  471.     } else
  472.     if (strcmp (Name, N_windowcycling) == 0)
  473.     {
  474.         i = globalflags.Windowcycling ? 1 : 0;
  475.         found = 1;
  476.     /* aborted */
  477.     } /* if */
  478.  
  479.     if (found)
  480.     {
  481.     sprintf(buffer,"%ld",i);
  482.     if (str = strdup(buffer))
  483.     {
  484.         return(str);
  485.     } else
  486.     {
  487.         nomemory();
  488.         abort(NULL);
  489.     } /* if */
  490.     } /* if */
  491.     return(NULL);
  492. } /* GetSpecialFlag */
  493.  
  494.  
  495.  
  496. /*
  497.  *  SetSpecialInt - Set a special Integer variable
  498.  *
  499.  *  >Name  - name of the variable to modify
  500.  *  >value - new value of the variable
  501.  *  <0 == name not found or value was no integer
  502.  *  <1 == name found (also if variable is write only)
  503.  */
  504.  
  505. char
  506. SetSpecialInt(char* name, char* value)
  507. {
  508.     int   val;
  509.     char found = 0;
  510.  
  511. /* printf("Is=%s\n",name); */
  512.     if (!is_number(value))
  513.     {  /* --- that is not correct but easy */
  514.     return(0);
  515.     } /* if */
  516.     val = atoi(value);
  517.  
  518.  
  519.     if ((strcmp (name, N_bgpen) == 0) ||
  520.       (strcmp (name, N_colno) == 0) ||
  521.       (strcmp (name, N_lineno) == 0) ||
  522.       (strcmp (name, N_fgpen) == 0) ||
  523.       (strcmp (name, N_hgpen) == 0) ||
  524.       (strcmp (name, N_tpen) == 0))
  525.       {
  526.         abort(1);
  527.     } else
  528.     if (strcmp (name, N_ascii) == 0)
  529.     {
  530.         if (!Ep->viewmode)
  531.         {
  532.         Current[Ep->column] = val / LINE_LENGTH;
  533.         } /* if */
  534.     } else
  535.     if (strcmp (name, N_margin) == 0)
  536.     {
  537.         Ep->config.margin = val % (LINE_LENGTH);
  538.     } else
  539.     if (strcmp (name, N_parcol) == 0)
  540.     {
  541.         Ep->config.wwcol = val % (LINE_LENGTH);
  542.     } else
  543.     if (strcmp (name, N_tabstop) == 0)
  544.     {
  545.         Ep->config.tabstop = val % (LINE_LENGTH);
  546.     } else
  547.     {
  548.         return(0);  /* not found */
  549.     } /* if */
  550.     return(1);      /* found */
  551. } /* SetSpecialInt */
  552.  
  553.  
  554.  
  555. /*
  556.  *  SetSpecialFlag - Set a specialFlag
  557.  *
  558.  *  >Name  - name of the variable to modify
  559.  *  >value - new value of the variable
  560.  *  <0 == name not found
  561.  *  <1 == ok ( also if other error)
  562.  */
  563.  
  564. char
  565. SetSpecialFlag(char* name, char* value)
  566. {
  567.     char* comment;
  568.     char  buffer[32];
  569.     char* com[2];
  570.     BOOL  oldmode;
  571.     BOOL  newmode;
  572.     BOOL  fetch;    /* TRUE, wenn oldmode gelesen werden soll */
  573.  
  574.     comment = NULL;
  575.     com[0]  = "Off";
  576.     com[1]  = "On";
  577.     fetch   = TRUE;
  578.  
  579. /* printf("Fs=%s\n",name); */
  580. /* --- local flags */
  581.  
  582.     for (;;)
  583.     {
  584.     if (strcmp (name, N_autounblock) == 0)
  585.     {
  586.         if (fetch)
  587.         oldmode = Ep->config.autounblock;
  588.         else
  589.         Ep->config.autounblock = newmode;
  590.         comment = "Autounblock";
  591.     } else if (strcmp (name, N_autoindent) == 0) {
  592.         if (fetch)
  593.         oldmode = Ep->config.autoindent;
  594.         else
  595.         Ep->config.autoindent = newmode;
  596.         comment = "Autoindent";
  597.     } else
  598.     if (strcmp (name, N_autosplit) == 0)
  599.     {
  600.         if (fetch)
  601.         oldmode = Ep->config.autosplit;
  602.         else
  603.         Ep->config.autosplit = newmode;
  604.         comment = "Autosplit";
  605.     } else
  606.     if (strcmp (name, N_ignorecase) == 0)
  607.     {   /* search case <-> ignorecase */
  608.         if (fetch)
  609.         oldmode = Ep->config.ignorecase;
  610.         else
  611.         Ep->config.ignorecase = newmode;
  612.         comment = "Case";
  613.         com[0]  = "Sensitive";
  614.         com[1]  = "InSensitive";
  615.     } else
  616.     if (strcmp (name, N_insertmode) == 0)
  617.     {   /* <-> overwrite text */
  618.         if (fetch)
  619.         oldmode = Ep->config.insertmode;
  620.         else
  621.         Ep->config.insertmode = newmode;
  622.         comment = "Insert mode";
  623.     } else
  624.     if (strcmp (name, N_wordwrap) == 0)
  625.     {
  626.         if (fetch)
  627.         oldmode = Ep->config.wordwrap;
  628.         else
  629.         Ep->config.wordwrap = newmode;
  630.         comment = "WordWrap";
  631.     } else
  632.     if (strcmp (name, N_viewmode) == 0)
  633.     {
  634.         if (fetch)
  635.         oldmode = Ep->viewmode;
  636.         else
  637.         Ep->viewmode = newmode;
  638.         comment = "Viewmode";
  639.     } else
  640.     if (strcmp (name, N_modified) == 0)
  641.     {     /* text-modified */
  642.         if (fetch)
  643.         oldmode = Ep->modified;
  644.         else
  645.         Ep->modified = newmode;
  646.         comment = "Modified";
  647.     }
  648.     /* --- global flags */
  649.     else if (strcmp (name, N_activetofront) == 0)
  650.     {
  651.         if (fetch)
  652.         oldmode = globalflags.ActivateToFront;
  653.         else
  654.         globalflags.ActivateToFront = newmode;
  655.         comment = "Moving Activated Windows To Front";
  656.     } else
  657.     if (strcmp (name, N_debug) == 0)
  658.     {
  659.         if (fetch)
  660.         oldmode = globalflags.debug;
  661.         else
  662.         globalflags.debug = newmode;
  663.         comment = "Debugging mode";
  664.     } else
  665.     if (strcmp (name, N_globalsearch) == 0)
  666.     {
  667.         if (fetch)
  668.         oldmode = globalflags.global_search;
  669.         else
  670.         globalflags.global_search = newmode;
  671.         comment = "Global Searching";
  672.     } else
  673. #ifdef NOTDEF
  674.     if (strcmp (name, N_infixmode) == 0)
  675.     {    /* math infixmode <-> prefixmode */
  676.         if (fetch)
  677.         oldmode = globalflags.MathInfix;
  678.         else
  679.         globalflags.MathInfix = newmode;
  680.         comment = "Infixmode";
  681.     } else
  682. #endif
  683.     if (strcmp (name, N_savetabs) == 0)
  684.     {     /* save tabs or whitespaces */
  685.         if (fetch)
  686.         oldmode = globalflags.Savetabs;
  687.         else
  688.         globalflags.Savetabs = newmode;
  689.         comment = "SaveTabs";
  690.     } else
  691.     if (strcmp (name, N_windowcycling) == 0)
  692.     {
  693.         if (fetch)
  694.         oldmode = globalflags.Windowcycling;
  695.         else
  696.         globalflags.Windowcycling = newmode;
  697.         comment = "Windowcycling";
  698.     } /* if */
  699.  
  700.     if (!fetch)
  701.         break;
  702.  
  703.     if (!comment)
  704.         return (0);
  705.  
  706.     newmode = test_arg (value, oldmode);
  707.     fetch = FALSE;
  708.  
  709.     sprintf(buffer,"%s %s ",comment, com[newmode]);
  710.     title(buffer);
  711.     }
  712.  
  713.     return (1); /* found */
  714. } /* SetSpecialFlag */
  715.  
  716.  
  717.  
  718. /*
  719.  *    This function is to be called for all toggling any special flag
  720.  *    via a command:        flagname mode
  721.  *  The only thing is - the variable must be treated here
  722.  */
  723.  
  724. void
  725. do_togglespecialflag()
  726. {
  727.     if (!SetSpecialFlag(av[0],av[1]))
  728.     abort();
  729. } /* do_togglespecialflag */
  730.  
  731.  
  732.  
  733. /*
  734.  *    This function might be called for all setting any special var
  735.  *    via a command:        varname mode
  736.  *  The only thing is - the variable must be treated here
  737.  */
  738.  
  739. void
  740. do_setspecialvar()
  741. {
  742.     if ( !SetSpecialInt(av[0],av[1])
  743.       && !SetSpecialVar(av[0],av[1]) )
  744.     abort();
  745. } /* do_setspecialvar */
  746.  
  747.  
  748. /*
  749. **  Redefine these names to adjust the used buffers to Your settings
  750. **  the commands are 'atomic' so there should be no interference to
  751. **  other 'atomic' commands using them.
  752. **
  753. **  for XDME changed buffers[0]/buffers[1] to tmp_buffer/tmp_buf2
  754. */
  755. #define firstbuffer  tmp_buffer
  756.  
  757.  
  758.  
  759.  
  760. /*
  761. *!  $[SPC.]currentword
  762. *!    that read-only special-variable
  763. *!    represents "the word under the cursor"
  764. *!    that means it finds the beginning of the current word on
  765. *!    on its own (but we do not move the cursor) if cursor is
  766. *!    not within a word, it returns the next word of the line
  767. *!    if there is no next word, an empty string is returned
  768. *!  NOTE this variable is not accessible, if PATCH_VARS is not active
  769. *!
  770. **  current_word           (uses firstbuffer)
  771. **
  772. **  Returns the word under the cursor,
  773. **  is used by fastscan and should be used by ref and tag instead of
  774. **  their own functions
  775. */
  776.  
  777. #define isC(ch)     (isalnum((ch)) || (ch) == '_')
  778.  
  779. char * current_word (void)
  780. {
  781.     register char* str;
  782.     register int i,j;
  783.  
  784.     str = firstbuffer;
  785.  
  786.     i = Ep->column;
  787.     while ((i>0) && isC(Current[i]))
  788.     {           /*  goto beginning of word */
  789.     i--;
  790.     } /* while */
  791.     while ((Current[i]) && !isC(Current[i]))
  792.     {  /* skip spaces and other garbage */
  793.     i++;
  794.     } /* while */
  795.  
  796.     j = 0;
  797.     while (isC(Current[i]) && (j <= LINE_LENGTH))
  798.     {
  799.     str[j] = Current[i];                /* copy "word" into buffer */
  800.     j++;
  801.     i++;
  802.     } /* while */
  803.     str[j] = 0;
  804.  
  805.     return (str);
  806. } /* current_word */
  807.  
  808.  
  809. /******************************************************************************
  810. *****  ENDE smallspc.c
  811. ******************************************************************************/
  812.