mirror of
https://github.com/rfivet/uemacs.git
synced 2024-11-16 09:36:29 -05:00
Move magic related definitions from estruct.h to search.c. Review search.h accordingly.
This commit is contained in:
parent
870989f948
commit
f99fe6fe54
4
Makefile
4
Makefile
@ -180,8 +180,8 @@ random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \
|
||||
window.h defines.h
|
||||
region.o: region.c region.h line.h utf8.h buffer.h crypt.h estruct.h \
|
||||
retcode.h edef.h log.h window.h defines.h
|
||||
search.o: search.c search.h estruct.h retcode.h basic.h buffer.h crypt.h \
|
||||
line.h utf8.h display.h edef.h input.h log.h window.h defines.h
|
||||
search.o: search.c search.h line.h utf8.h basic.h buffer.h crypt.h \
|
||||
display.h edef.h estruct.h retcode.h input.h log.h window.h defines.h
|
||||
spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \
|
||||
display.h estruct.h retcode.h edef.h file.h flook.h input.h log.h \
|
||||
window.h
|
||||
|
56
estruct.h
56
estruct.h
@ -157,8 +157,8 @@
|
||||
#define APROP 1 /* Add code for Apropos command */
|
||||
#if 0
|
||||
#define CRYPT 1 /* file encryption enabled? */
|
||||
#endif
|
||||
#define MAGIC 1 /* include regular expression matching? */
|
||||
#endif
|
||||
#define AEDIT 1 /* advanced editing options: en/detabbing */
|
||||
#define PROC 1 /* named procedures */
|
||||
#define CLEAN 0 /* de-alloc memory on exit */
|
||||
@ -503,59 +503,5 @@ struct while_block {
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(MAGIC)
|
||||
/*
|
||||
* Defines for the metacharacters in the regular expression
|
||||
* search routines.
|
||||
*/
|
||||
#define MCNIL 0 /* Like the '\0' for strings. */
|
||||
#define LITCHAR 1 /* Literal character, or string. */
|
||||
#define ANY 2
|
||||
#define CCL 3
|
||||
#define NCCL 4
|
||||
#define BOL 5
|
||||
#define EOL 6
|
||||
#define DITTO 7
|
||||
#define CLOSURE 256 /* An or-able value. */
|
||||
#define MASKCL (CLOSURE - 1)
|
||||
|
||||
#define MC_ANY '.' /* 'Any' character (except newline). */
|
||||
#define MC_CCL '[' /* Character class. */
|
||||
#define MC_NCCL '^' /* Negate character class. */
|
||||
#define MC_RCCL '-' /* Range in character class. */
|
||||
#define MC_ECCL ']' /* End of character class. */
|
||||
#define MC_BOL '^' /* Beginning of line. */
|
||||
#define MC_EOL '$' /* End of line. */
|
||||
#define MC_CLOSURE '*' /* Closure - does not extend past newline. */
|
||||
#define MC_DITTO '&' /* Use matched string in replacement. */
|
||||
#define MC_ESC '\\' /* Escape - suppress meta-meaning. */
|
||||
|
||||
#define BIT(n) (1 << (n)) /* An integer with one bit set. */
|
||||
#define CHCASE(c) ((c) ^ DIFCASE) /* Toggle the case of a letter. */
|
||||
|
||||
/* HICHAR - 1 is the largest character we will deal with.
|
||||
* HIBYTE represents the number of bytes in the bitmap.
|
||||
*/
|
||||
#define HICHAR 256
|
||||
#define HIBYTE HICHAR >> 3
|
||||
|
||||
/* Typedefs that define the meta-character structure for MAGIC mode searching
|
||||
* (struct magic), and the meta-character structure for MAGIC mode replacement
|
||||
* (struct magic_replacement).
|
||||
*/
|
||||
struct magic {
|
||||
short int mc_type;
|
||||
union {
|
||||
int lchar;
|
||||
char *cclmap;
|
||||
} u;
|
||||
};
|
||||
|
||||
struct magic_replacement {
|
||||
short int mc_type;
|
||||
char *rstr;
|
||||
};
|
||||
|
||||
#endif /* MAGIC */
|
||||
|
||||
#endif
|
||||
|
57
search.c
57
search.c
@ -65,7 +65,6 @@
|
||||
#include "basic.h"
|
||||
#include "buffer.h"
|
||||
#include "display.h"
|
||||
#include "estruct.h"
|
||||
#include "edef.h"
|
||||
#include "input.h"
|
||||
#include "line.h"
|
||||
@ -73,6 +72,58 @@
|
||||
#include "window.h"
|
||||
|
||||
#if defined(MAGIC)
|
||||
/*
|
||||
* Defines for the metacharacters in the regular expression
|
||||
* search routines.
|
||||
*/
|
||||
#define MCNIL 0 /* Like the '\0' for strings. */
|
||||
#define LITCHAR 1 /* Literal character, or string. */
|
||||
#define ANY 2
|
||||
#define CCL 3
|
||||
#define NCCL 4
|
||||
#define BOL 5
|
||||
#define EOL 6
|
||||
#define DITTO 7
|
||||
#define CLOSURE 256 /* An or-able value. */
|
||||
#define MASKCL (CLOSURE - 1)
|
||||
|
||||
#define MC_ANY '.' /* 'Any' character (except newline). */
|
||||
#define MC_CCL '[' /* Character class. */
|
||||
#define MC_NCCL '^' /* Negate character class. */
|
||||
#define MC_RCCL '-' /* Range in character class. */
|
||||
#define MC_ECCL ']' /* End of character class. */
|
||||
#define MC_BOL '^' /* Beginning of line. */
|
||||
#define MC_EOL '$' /* End of line. */
|
||||
#define MC_CLOSURE '*' /* Closure - does not extend past newline. */
|
||||
#define MC_DITTO '&' /* Use matched string in replacement. */
|
||||
#define MC_ESC '\\' /* Escape - suppress meta-meaning. */
|
||||
|
||||
#define BIT(n) (1 << (n)) /* An integer with one bit set. */
|
||||
#define CHCASE(c) ((c) ^ DIFCASE) /* Toggle the case of a letter. */
|
||||
|
||||
/* HICHAR - 1 is the largest character we will deal with.
|
||||
* HIBYTE represents the number of bytes in the bitmap.
|
||||
*/
|
||||
#define HICHAR 256
|
||||
#define HIBYTE HICHAR >> 3
|
||||
|
||||
/* Typedefs that define the meta-character structure for MAGIC mode searching
|
||||
* (struct magic), and the meta-character structure for MAGIC mode replacement
|
||||
* (struct magic_replacement).
|
||||
*/
|
||||
struct magic {
|
||||
short int mc_type;
|
||||
union {
|
||||
int lchar;
|
||||
char *cclmap;
|
||||
} u;
|
||||
};
|
||||
|
||||
struct magic_replacement {
|
||||
short int mc_type;
|
||||
char *rstr;
|
||||
};
|
||||
|
||||
/*
|
||||
* The variables magical and rmagical determine if there
|
||||
* were actual metacharacters in the search and replace strings -
|
||||
@ -84,6 +135,8 @@ static short int rmagical;
|
||||
static struct magic mcpat[NPAT]; /* The magic pattern. */
|
||||
static struct magic tapcm[NPAT]; /* The reversed magic patterni. */
|
||||
static struct magic_replacement rmcpat[NPAT]; /* The replacement magic array. */
|
||||
|
||||
static int mcscanner( struct magic *mcpatrn, int direct, int beg_or_end) ;
|
||||
#endif
|
||||
|
||||
static int amatch(struct magic *mcptr, int direct, struct line **pcwline, int *pcwoff);
|
||||
@ -309,7 +362,7 @@ int backhunt(int f, int n)
|
||||
* int direct; which way to go.
|
||||
* int beg_or_end; put point at beginning or end of pattern.
|
||||
*/
|
||||
int mcscanner(struct magic *mcpatrn, int direct, int beg_or_end)
|
||||
static int mcscanner(struct magic *mcpatrn, int direct, int beg_or_end)
|
||||
{
|
||||
struct line *curline; /* current line during scan */
|
||||
int curoff; /* position within current line */
|
||||
|
8
search.h
8
search.h
@ -1,13 +1,14 @@
|
||||
#ifndef _SEARCH_H_
|
||||
#define _SEARCH_H_
|
||||
|
||||
#include "estruct.h"
|
||||
#define MAGIC 1
|
||||
|
||||
#include "line.h"
|
||||
|
||||
int forwsearch( int f, int n) ;
|
||||
int forwhunt( int f, int n) ;
|
||||
int backsearch( int f, int n) ;
|
||||
int backhunt( int f, int n) ;
|
||||
int mcscanner( struct magic *mcpatrn, int direct, int beg_or_end) ;
|
||||
int scanner( const char *patrn, int direct, int beg_or_end) ;
|
||||
int eq( unsigned char bc, unsigned char pc) ;
|
||||
void savematch( void) ;
|
||||
@ -17,7 +18,10 @@ int qreplace( int f, int n) ;
|
||||
int delins( int dlength, char *instr, int use_meta) ;
|
||||
int expandp( char *srcstr, char *deststr, int maxlength) ;
|
||||
int boundry( struct line *curline, int curoff, int dir) ;
|
||||
|
||||
#if MAGIC
|
||||
void mcclear( void) ;
|
||||
void rmcclear( void) ;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user