home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / STVI369G.ZIP / SOURCE.DOC < prev    next >
Text File  |  1990-05-01  |  3KB  |  96 lines

  1.  
  2.          Release Notes for STEVIE - Version 3.68
  3.  
  4.                   Source Notes
  5.  
  6.                   Tony Andrews
  7.  
  8.                    8/6/89
  9.  
  10.  
  11. Overview
  12. --------
  13.  
  14.     This file provides a brief description of the source code for
  15. Stevie. The data structures are described later as well. For information
  16. specific to porting the editor, see the file 'porting.doc'. This document
  17. is more relevant to people who want to hack on the editor apart from doing
  18. a simple port.
  19.  
  20.     Most of this document was written some time ago so a lot of the
  21. discussion centers on problems related to the Atari ST environment and
  22. compilers. Most of this can be ignored for other systems.
  23.  
  24.  
  25. Cruft
  26. -----
  27.  
  28.     Older versions of the editor used Henry Spencer's regular
  29. expression library directly. The current version incorporates a modified
  30. version of that same library.
  31.  
  32.  
  33. Data Structures
  34. ---------------
  35.  
  36.     A brief discussion of the evolution of the data structures will
  37. do much to clarify the code, and explain some of the strangeness you may
  38. see.
  39.  
  40.     In the original version, the file was maintained in memory as a
  41. simple contiguous buffer. References to positions in the file were simply
  42. character pointers. Due to the obvious performance problems inherent in
  43. this approach, I made the following changes.
  44.  
  45.     The file is now represented by a doubly linked list of 'line'
  46. structures defined as follows:
  47.  
  48. struct    line {
  49.     struct    line    *prev, *next;    /* previous and next lines */
  50.     char    *s;            /* text for this line */
  51.     int    size;            /* actual size of space at 's' */
  52.     unsigned long    num;        /* line "number" */
  53. };
  54.  
  55. The members of the line structure are:
  56.  
  57. prev    - pointer to the structure for the prior line, or NULL for the
  58.       first line of the file
  59.  
  60. next    - like 'prev' but points to the next line
  61.  
  62. s    - points to the contents of the line (null terminated)
  63.  
  64. size    - contains the size of the chunk of space pointed to by s. This
  65.       is used so we know when we can add text to a line without getting
  66.       more space. When we DO need more space, we always get a little
  67.       extra so we don't make so many calls to malloc.
  68.  
  69. num    - This is a pseudo line number that makes it easy to compare
  70.       positions within the file. Otherwise, we'd have to traverse
  71.       all the links to tell which line came first.
  72.  
  73.  
  74.     Since character pointers served to mark file positions in the
  75. original, a similar data object was needed for the new data structures.
  76. This purpose is served by the 'lptr' structure which is defined as:
  77.  
  78. struct    lptr {
  79.     struct    line    *linep;        /* line we're referencing */
  80.     int    index;            /* position within that line */
  81. };
  82.  
  83. The member 'linep' points to the 'line' structure for the line containing
  84. the location of interest. The integer 'index' is the offset into the line
  85. data (member 's') of the character to be referenced.
  86.  
  87. The following typedef's are more commonly used:
  88.  
  89. typedef    struct line    LINE;
  90. typedef    struct lptr    LPTR;
  91.  
  92. Many operations that were trivial with character pointers had to be
  93. implemented by functions to manipulate LPTR's. Most of these are in the
  94. file 'ptrfunc.c'. There you'll find functions to increment, decrement,
  95. and compare LPTR's.
  96.