mirror of
https://git.code.sf.net/p/fldigi/fldigi
synced 2026-08-13 17:47:54 -04:00
GCC 15 changes
* Changed regex 'C' declarations to current standards.
* Commented out frequency2 list legacy code, causes incorrect assignment.
* Minor changes to mode parsing.
* Added qso_browser clear() function to prevent list doubling on
each frequency2 file reading.
* Modified code to prevent duplicate entries.
This commit is contained in:
parent
fbce31a189
commit
c207d29c8e
4 changed files with 96 additions and 194 deletions
|
|
@ -49,7 +49,7 @@
|
|||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "regex.h"
|
||||
|
||||
/* Define the syntax stuff for \<, \>, etc. */
|
||||
|
||||
|
|
@ -70,8 +70,7 @@ extern char *re_syntax_table;
|
|||
|
||||
static char re_syntax_table[CHAR_SET_SIZE];
|
||||
|
||||
static void
|
||||
init_syntax_once ()
|
||||
static void init_syntax_once (void)
|
||||
{
|
||||
register int c;
|
||||
static int done = 0;
|
||||
|
|
@ -99,7 +98,6 @@ init_syntax_once ()
|
|||
|
||||
#define SYNTAX(c) re_syntax_table[c]
|
||||
|
||||
|
||||
/* Get the interface, including the syntax bits. */
|
||||
#include "regex.h"
|
||||
|
||||
|
|
@ -357,6 +355,10 @@ typedef enum
|
|||
} re_opcode_t;
|
||||
|
||||
/* Common operations on the compiled pattern. */
|
||||
static void store_op1 (re_opcode_t op, unsigned char *loc, int arg);
|
||||
static void store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2);
|
||||
static void insert_op1 (re_opcode_t op, unsigned char *loc, int arg, unsigned char *end);
|
||||
static void insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, unsigned char *end);
|
||||
|
||||
/* Store NUMBER in two contiguous bytes starting at DESTINATION. */
|
||||
|
||||
|
|
@ -386,10 +388,7 @@ typedef enum
|
|||
} while (0)
|
||||
|
||||
#ifdef DEBUG
|
||||
static void
|
||||
extract_number (dest, source)
|
||||
int *dest;
|
||||
unsigned char *source;
|
||||
static void extract_number (int *dest, unsigned char *source)
|
||||
{
|
||||
int temp = SIGN_EXTEND_CHAR (*(source + 1));
|
||||
*dest = *source & 0377;
|
||||
|
|
@ -413,10 +412,7 @@ extract_number (dest, source)
|
|||
} while (0)
|
||||
|
||||
#ifdef DEBUG
|
||||
static void
|
||||
extract_number_and_incr (destination, source)
|
||||
int *destination;
|
||||
unsigned char **source;
|
||||
static void extract_number_and_incr (int *destination, unsigned char **source)
|
||||
{
|
||||
extract_number (destination, *source);
|
||||
*source += 2;
|
||||
|
|
@ -461,9 +457,7 @@ extern void printchar ();
|
|||
|
||||
/* Print the fastmap in human-readable form. */
|
||||
|
||||
void
|
||||
print_fastmap (fastmap)
|
||||
char *fastmap;
|
||||
void print_fastmap (char *fastmap)
|
||||
{
|
||||
unsigned was_a_range = 0;
|
||||
unsigned i = 0;
|
||||
|
|
@ -701,9 +695,7 @@ print_partial_compiled_pattern (start, end)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
print_compiled_pattern (bufp)
|
||||
struct re_pattern_buffer *bufp;
|
||||
void print_compiled_pattern (struct re_pattern_buffer *bufp)
|
||||
{
|
||||
unsigned char *buffer = bufp->buffer;
|
||||
|
||||
|
|
@ -728,13 +720,8 @@ print_compiled_pattern (bufp)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
print_double_string (where, string1, size1, string2, size2)
|
||||
const char *where;
|
||||
const char *string1;
|
||||
const char *string2;
|
||||
int size1;
|
||||
int size2;
|
||||
void print_double_string (const char *where, const char *string1, int size1, \
|
||||
const char *string2, int size2)
|
||||
{
|
||||
unsigned this_char;
|
||||
|
||||
|
|
@ -783,9 +770,7 @@ reg_syntax_t re_syntax_options = RE_SYNTAX_EMACS;
|
|||
The argument SYNTAX is a bit mask comprised of the various bits
|
||||
defined in regex.h. We return the old syntax. */
|
||||
|
||||
reg_syntax_t
|
||||
re_set_syntax (syntax)
|
||||
reg_syntax_t syntax;
|
||||
reg_syntax_t re_set_syntax (reg_syntax_t syntax)
|
||||
{
|
||||
reg_syntax_t ret = re_syntax_options;
|
||||
|
||||
|
|
@ -818,11 +803,9 @@ static const char *re_error_msg[] =
|
|||
|
||||
/* Subroutine declarations and macros for regex_compile. */
|
||||
|
||||
static void store_op1 (), store_op2 ();
|
||||
static void insert_op1 (), insert_op2 ();
|
||||
static boolean at_begline_loc_p (), at_endline_loc_p ();
|
||||
static boolean group_in_compile_stack ();
|
||||
static reg_errcode_t compile_range ();
|
||||
static boolean at_begline_loc_p (const char *pattern, const char *p, reg_syntax_t syntax);
|
||||
static boolean at_endline_loc_p (const char *p, const char *pend, int syntax);
|
||||
static reg_errcode_t compile_range (const char **p_ptr, const char *pend, char *translate, reg_syntax_t syntax, unsigned char *b);
|
||||
|
||||
/* Fetch the next character in the uncompiled pattern---translating it
|
||||
if necessary. Also cast from a signed character in the constant
|
||||
|
|
@ -976,6 +959,7 @@ typedef struct
|
|||
unsigned avail; /* Offset of next open position. */
|
||||
} compile_stack_type;
|
||||
|
||||
static boolean group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum);
|
||||
|
||||
#define INIT_COMPILE_STACK_SIZE 32
|
||||
|
||||
|
|
@ -1037,12 +1021,8 @@ typedef struct
|
|||
The `fastmap' and `newline_anchor' fields are neither
|
||||
examined nor set. */
|
||||
|
||||
static reg_errcode_t
|
||||
regex_compile (pattern, size, syntax, bufp)
|
||||
const char *pattern;
|
||||
int size;
|
||||
reg_syntax_t syntax;
|
||||
struct re_pattern_buffer *bufp;
|
||||
static reg_errcode_t regex_compile (const char *pattern, int size, \
|
||||
reg_syntax_t syntax, struct re_pattern_buffer *bufp)
|
||||
{
|
||||
/* We fetch characters from PATTERN here. Even though PATTERN is
|
||||
`char *' (i.e., signed), we declare these variables as unsigned, so
|
||||
|
|
@ -2044,11 +2024,7 @@ regex_compile (pattern, size, syntax, bufp)
|
|||
|
||||
/* Store OP at LOC followed by two-byte integer parameter ARG. */
|
||||
|
||||
static void
|
||||
store_op1 (op, loc, arg)
|
||||
re_opcode_t op;
|
||||
unsigned char *loc;
|
||||
int arg;
|
||||
static void store_op1 (re_opcode_t op, unsigned char *loc, int arg)
|
||||
{
|
||||
*loc = (unsigned char) op;
|
||||
STORE_NUMBER (loc + 1, arg);
|
||||
|
|
@ -2057,11 +2033,7 @@ store_op1 (op, loc, arg)
|
|||
|
||||
/* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */
|
||||
|
||||
static void
|
||||
store_op2 (op, loc, arg1, arg2)
|
||||
re_opcode_t op;
|
||||
unsigned char *loc;
|
||||
int arg1, arg2;
|
||||
static void store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2)
|
||||
{
|
||||
*loc = (unsigned char) op;
|
||||
STORE_NUMBER (loc + 1, arg1);
|
||||
|
|
@ -2072,12 +2044,8 @@ store_op2 (op, loc, arg1, arg2)
|
|||
/* Copy the bytes from LOC to END to open up three bytes of space at LOC
|
||||
for OP followed by two-byte integer parameter ARG. */
|
||||
|
||||
static void
|
||||
insert_op1 (op, loc, arg, end)
|
||||
re_opcode_t op;
|
||||
unsigned char *loc;
|
||||
int arg;
|
||||
unsigned char *end;
|
||||
static void insert_op1 (re_opcode_t op, unsigned char *loc, \
|
||||
int arg, unsigned char *end)
|
||||
{
|
||||
register unsigned char *pfrom = end;
|
||||
register unsigned char *pto = end + 3;
|
||||
|
|
@ -2091,12 +2059,8 @@ insert_op1 (op, loc, arg, end)
|
|||
|
||||
/* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */
|
||||
|
||||
static void
|
||||
insert_op2 (op, loc, arg1, arg2, end)
|
||||
re_opcode_t op;
|
||||
unsigned char *loc;
|
||||
int arg1, arg2;
|
||||
unsigned char *end;
|
||||
static void insert_op2 (re_opcode_t op, unsigned char *loc, \
|
||||
int arg1, int arg2, unsigned char *end)
|
||||
{
|
||||
register unsigned char *pfrom = end;
|
||||
register unsigned char *pto = end + 5;
|
||||
|
|
@ -2112,10 +2076,7 @@ insert_op2 (op, loc, arg1, arg2, end)
|
|||
after an alternative or a begin-subexpression. We assume there is at
|
||||
least one character before the ^. */
|
||||
|
||||
static boolean
|
||||
at_begline_loc_p (pattern, p, syntax)
|
||||
const char *pattern, *p;
|
||||
reg_syntax_t syntax;
|
||||
static boolean at_begline_loc_p (const char *pattern, const char *p, reg_syntax_t syntax)
|
||||
{
|
||||
const char *prev = p - 2;
|
||||
boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\';
|
||||
|
|
@ -2131,10 +2092,7 @@ at_begline_loc_p (pattern, p, syntax)
|
|||
/* The dual of at_begline_loc_p. This one is for $. We assume there is
|
||||
at least one character after the $, i.e., `P < PEND'. */
|
||||
|
||||
static boolean
|
||||
at_endline_loc_p (p, pend, syntax)
|
||||
const char *p, *pend;
|
||||
int syntax;
|
||||
static boolean at_endline_loc_p (const char *p, const char *pend, int syntax)
|
||||
{
|
||||
const char *next = p;
|
||||
boolean next_backslash = *next == '\\';
|
||||
|
|
@ -2153,10 +2111,7 @@ at_endline_loc_p (p, pend, syntax)
|
|||
/* Returns true if REGNUM is in one of COMPILE_STACK's elements and
|
||||
false if it's not. */
|
||||
|
||||
static boolean
|
||||
group_in_compile_stack (compile_stack, regnum)
|
||||
compile_stack_type compile_stack;
|
||||
regnum_t regnum;
|
||||
static boolean group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum)
|
||||
{
|
||||
int this_element;
|
||||
|
||||
|
|
@ -2181,12 +2136,8 @@ group_in_compile_stack (compile_stack, regnum)
|
|||
We use these short variable names so we can use the same macros as
|
||||
`regex_compile' itself. */
|
||||
|
||||
static reg_errcode_t
|
||||
compile_range (p_ptr, pend, translate, syntax, b)
|
||||
const char **p_ptr, *pend;
|
||||
char *translate;
|
||||
reg_syntax_t syntax;
|
||||
unsigned char *b;
|
||||
static reg_errcode_t compile_range (const char **p_ptr, const char *pend, char *translate, \
|
||||
reg_syntax_t syntax, unsigned char *b)
|
||||
{
|
||||
unsigned this_char;
|
||||
|
||||
|
|
@ -2513,9 +2464,7 @@ typedef struct
|
|||
|
||||
Returns 0 if we succeed, -2 if an internal error. */
|
||||
|
||||
int
|
||||
re_compile_fastmap (bufp)
|
||||
struct re_pattern_buffer *bufp;
|
||||
int re_compile_fastmap (struct re_pattern_buffer *bufp)
|
||||
{
|
||||
int j, k;
|
||||
fail_stack_type fail_stack;
|
||||
|
|
@ -2798,12 +2747,8 @@ re_compile_fastmap (bufp)
|
|||
PATTERN_BUFFER will allocate its own register data, without
|
||||
freeing the old data. */
|
||||
|
||||
void
|
||||
re_set_registers (bufp, regs, num_regs, starts, ends)
|
||||
struct re_pattern_buffer *bufp;
|
||||
struct re_registers *regs;
|
||||
unsigned num_regs;
|
||||
regoff_t *starts, *ends;
|
||||
void re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, \
|
||||
unsigned num_regs, regoff_t *starts, regoff_t *ends)
|
||||
{
|
||||
if (num_regs)
|
||||
{
|
||||
|
|
@ -2825,12 +2770,8 @@ re_set_registers (bufp, regs, num_regs, starts, ends)
|
|||
/* Like re_search_2, below, but only one string is specified, and
|
||||
doesn't let you say where to stop matching. */
|
||||
|
||||
int
|
||||
re_search (bufp, string, size, startpos, range, regs)
|
||||
struct re_pattern_buffer *bufp;
|
||||
const char *string;
|
||||
int size, startpos, range;
|
||||
struct re_registers *regs;
|
||||
int re_search (struct re_pattern_buffer *bufp, const char *string, int size, int startpos, \
|
||||
int range, struct re_registers *regs)
|
||||
{
|
||||
return re_search_2 (bufp, NULL, 0, string, size, startpos, range,
|
||||
regs, size);
|
||||
|
|
@ -2858,15 +2799,9 @@ re_search (bufp, string, size, startpos, range, regs)
|
|||
found, -1 if no match, or -2 if error (such as failure
|
||||
stack overflow). */
|
||||
|
||||
int
|
||||
re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
|
||||
struct re_pattern_buffer *bufp;
|
||||
const char *string1, *string2;
|
||||
int size1, size2;
|
||||
int startpos;
|
||||
int range;
|
||||
struct re_registers *regs;
|
||||
int stop;
|
||||
int re_search_2 (struct re_pattern_buffer *bufp, const char *string1, \
|
||||
int size1, const char *string2, int size2, int startpos, int range, \
|
||||
struct re_registers *regs, int stop)
|
||||
{
|
||||
int val;
|
||||
register char *fastmap = bufp->fastmap;
|
||||
|
|
@ -2976,11 +2911,6 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
|
|||
|
||||
/* Declarations and macros for re_match_2. */
|
||||
|
||||
static int bcmp_translate ();
|
||||
static boolean alt_match_null_string_p (),
|
||||
common_op_match_null_string_p (),
|
||||
group_match_null_string_p ();
|
||||
|
||||
/* Structure for per-register (a.k.a. per-group) information.
|
||||
This must not be longer than one word, because we push this value
|
||||
onto the failure stack. Other register information, such as the
|
||||
|
|
@ -3007,6 +2937,11 @@ typedef union
|
|||
} bits;
|
||||
} register_info_type;
|
||||
|
||||
static int bcmp_translate(unsigned char *s1, unsigned char *s2, int len, char *translate);
|
||||
static boolean alt_match_null_string_p (unsigned char *p, unsigned char *end, register_info_type *reg_info);
|
||||
static boolean common_op_match_null_string_p (unsigned char **p, unsigned char *end, register_info_type *reg_info);
|
||||
static boolean group_match_null_string_p (unsigned char **p, unsigned char *end, register_info_type *reg_info);
|
||||
|
||||
#define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p)
|
||||
#define IS_ACTIVE(R) ((R).bits.is_active)
|
||||
#define MATCHED_SOMETHING(R) ((R).bits.matched_something)
|
||||
|
|
@ -3117,12 +3052,8 @@ typedef union
|
|||
#ifndef emacs /* Emacs never uses this. */
|
||||
/* re_match is like re_match_2 except it takes only a single string. */
|
||||
|
||||
int
|
||||
re_match (bufp, string, size, pos, regs)
|
||||
struct re_pattern_buffer *bufp;
|
||||
const char *string;
|
||||
int size, pos;
|
||||
struct re_registers *regs;
|
||||
int re_match (struct re_pattern_buffer *bufp, const char *string, \
|
||||
int size, int pos, struct re_registers *regs)
|
||||
{
|
||||
return re_match_2 (bufp, NULL, 0, string, size, pos, regs, size);
|
||||
}
|
||||
|
|
@ -3142,14 +3073,8 @@ re_match (bufp, string, size, pos, regs)
|
|||
failure stack overflowing). Otherwise, we return the length of the
|
||||
matched substring. */
|
||||
|
||||
int
|
||||
re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
|
||||
struct re_pattern_buffer *bufp;
|
||||
const char *string1, *string2;
|
||||
int size1, size2;
|
||||
int pos;
|
||||
struct re_registers *regs;
|
||||
int stop;
|
||||
int re_match_2 (struct re_pattern_buffer *bufp, const char *string1, int size1, const char *string2, int size2, \
|
||||
int pos, struct re_registers *regs, int stop)
|
||||
{
|
||||
/* General temporaries. */
|
||||
int mcnt;
|
||||
|
|
@ -4340,10 +4265,8 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
|
|||
|
||||
We don't handle duplicates properly (yet). */
|
||||
|
||||
static boolean
|
||||
group_match_null_string_p (p, end, reg_info)
|
||||
unsigned char **p, *end;
|
||||
register_info_type *reg_info;
|
||||
static boolean group_match_null_string_p (unsigned char **p, unsigned char *end, \
|
||||
register_info_type *reg_info)
|
||||
{
|
||||
int mcnt;
|
||||
/* Point to after the args to the start_memory. */
|
||||
|
|
@ -4449,10 +4372,8 @@ group_match_null_string_p (p, end, reg_info)
|
|||
It expects P to be the first byte of a single alternative and END one
|
||||
byte past the last. The alternative can contain groups. */
|
||||
|
||||
static boolean
|
||||
alt_match_null_string_p (p, end, reg_info)
|
||||
unsigned char *p, *end;
|
||||
register_info_type *reg_info;
|
||||
static boolean alt_match_null_string_p (unsigned char *p, unsigned char *end, \
|
||||
register_info_type *reg_info)
|
||||
{
|
||||
int mcnt;
|
||||
unsigned char *p1 = p;
|
||||
|
|
@ -4486,10 +4407,8 @@ alt_match_null_string_p (p, end, reg_info)
|
|||
|
||||
Sets P to one after the op and its arguments, if any. */
|
||||
|
||||
static boolean
|
||||
common_op_match_null_string_p (p, end, reg_info)
|
||||
unsigned char **p, *end;
|
||||
register_info_type *reg_info;
|
||||
static boolean common_op_match_null_string_p (unsigned char **p, unsigned char *end, \
|
||||
register_info_type *reg_info)
|
||||
{
|
||||
int mcnt;
|
||||
boolean ret;
|
||||
|
|
@ -4517,7 +4436,7 @@ common_op_match_null_string_p (p, end, reg_info)
|
|||
case start_memory:
|
||||
reg_no = *p1;
|
||||
assert (reg_no > 0 && reg_no <= MAX_REGNUM);
|
||||
ret = group_match_null_string_p (&p1, end, reg_info);
|
||||
ret = (boolean) group_match_null_string_p (&p1, end, reg_info);
|
||||
|
||||
/* Have to set this here in case we're checking a group which
|
||||
contains a group and a back reference to it. */
|
||||
|
|
@ -4574,13 +4493,8 @@ common_op_match_null_string_p (p, end, reg_info)
|
|||
/* Return zero if TRANSLATE[S1] and TRANSLATE[S2] are identical for LEN
|
||||
bytes; nonzero otherwise. */
|
||||
|
||||
static int
|
||||
bcmp_translate(
|
||||
unsigned char *s1,
|
||||
unsigned char *s2,
|
||||
int len,
|
||||
char *translate
|
||||
)
|
||||
static int bcmp_translate(unsigned char *s1, unsigned char *s2, int len, \
|
||||
char *translate)
|
||||
{
|
||||
register unsigned char *p1 = s1, *p2 = s2;
|
||||
while (len)
|
||||
|
|
@ -4602,11 +4516,7 @@ bcmp_translate(
|
|||
|
||||
We call regex_compile to do the actual compilation. */
|
||||
|
||||
const char *
|
||||
re_compile_pattern (pattern, length, bufp)
|
||||
const char *pattern;
|
||||
int length;
|
||||
struct re_pattern_buffer *bufp;
|
||||
const char * re_compile_pattern (const char *pattern, int length, struct re_pattern_buffer *bufp )
|
||||
{
|
||||
reg_errcode_t ret;
|
||||
|
||||
|
|
@ -4635,9 +4545,7 @@ re_compile_pattern (pattern, length, bufp)
|
|||
/* BSD has one and only one pattern buffer. */
|
||||
static struct re_pattern_buffer re_comp_buf;
|
||||
|
||||
char *
|
||||
re_comp (s)
|
||||
const char *s;
|
||||
char * re_comp (const char *s)
|
||||
{
|
||||
reg_errcode_t ret;
|
||||
|
||||
|
|
@ -4673,9 +4581,7 @@ re_comp (s)
|
|||
}
|
||||
|
||||
|
||||
int
|
||||
re_exec (s)
|
||||
const char *s;
|
||||
int re_exec (const char *s)
|
||||
{
|
||||
const int len = strlen (s);
|
||||
return
|
||||
|
|
@ -4721,11 +4627,7 @@ re_exec (s)
|
|||
It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for
|
||||
the return codes and their meanings.) */
|
||||
|
||||
int
|
||||
regcomp (preg, pattern, cflags)
|
||||
regex_t *preg;
|
||||
const char *pattern;
|
||||
int cflags;
|
||||
int regcomp (regex_t *preg, const char *pattern, int cflags)
|
||||
{
|
||||
reg_errcode_t ret;
|
||||
unsigned syntax
|
||||
|
|
@ -4796,13 +4698,7 @@ regcomp (preg, pattern, cflags)
|
|||
|
||||
We return 0 if we find a match and REG_NOMATCH if not. */
|
||||
|
||||
int
|
||||
regexec (preg, string, nmatch, pmatch, eflags)
|
||||
const regex_t *preg;
|
||||
const char *string;
|
||||
size_t nmatch;
|
||||
regmatch_t pmatch[];
|
||||
int eflags;
|
||||
int regexec (const regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags)
|
||||
{
|
||||
int ret;
|
||||
struct re_registers regs;
|
||||
|
|
@ -4864,12 +4760,7 @@ regexec (preg, string, nmatch, pmatch, eflags)
|
|||
/* Returns a message corresponding to an error code, ERRCODE, returned
|
||||
from either regcomp or regexec. We don't use PREG here. */
|
||||
|
||||
size_t
|
||||
regerror (errcode, preg, errbuf, errbuf_size)
|
||||
int errcode;
|
||||
const regex_t *preg;
|
||||
char *errbuf;
|
||||
size_t errbuf_size;
|
||||
size_t regerror (int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
|
||||
{
|
||||
const char *msg;
|
||||
size_t msg_size;
|
||||
|
|
@ -4908,9 +4799,7 @@ regerror (errcode, preg, errbuf, errbuf_size)
|
|||
|
||||
/* Free dynamically allocated space used by PREG. */
|
||||
|
||||
void
|
||||
regfree (preg)
|
||||
regex_t *preg;
|
||||
void regfree (regex_t *preg)
|
||||
{
|
||||
if (preg->buffer != NULL)
|
||||
free (preg->buffer);
|
||||
|
|
|
|||
|
|
@ -303,20 +303,24 @@ std::ostream& operator<<(std::ostream& s, const qrg_mode_t& m)
|
|||
|
||||
std::istream& operator>>(std::istream& s, qrg_mode_t& m)
|
||||
{
|
||||
std::string sMode;
|
||||
std::string sMode = "";
|
||||
char temp[255];
|
||||
int mnbr;
|
||||
s >> m.rfcarrier >> m.rmode >> m.carrier >> sMode;
|
||||
int mnbr = 0;
|
||||
|
||||
memset(temp, 0, sizeof(temp));
|
||||
|
||||
s >> m.rfcarrier >> m.rmode >> m.carrier >> sMode;
|
||||
s.getline(temp, 255);
|
||||
m.usage = temp;
|
||||
while (m.usage[0] == ' ') m.usage.erase(0,1);
|
||||
|
||||
// This causes incorrect assignment when modem name starts with a number (ex:8PSK)
|
||||
// handle case for reading older type of specification std::string
|
||||
if (sscanf(sMode.c_str(), "%d",&mnbr)) {
|
||||
m.mode = mnbr;
|
||||
return s;
|
||||
}
|
||||
// if (sscanf(sMode.c_str(), "%d",&mnbr)) {
|
||||
// m.mode = mnbr;
|
||||
// return s;
|
||||
// }
|
||||
|
||||
m.mode = MODE_PSK31;
|
||||
for (mnbr = MODE_CW; mnbr < NUM_MODES; mnbr++)
|
||||
if (sMode == mode_info[mnbr].sname) {
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ extern Cserial rigio;
|
|||
extern void initOptionMenus();
|
||||
extern void clearList();
|
||||
extern void updateSelect();
|
||||
extern size_t addtoList(long val);
|
||||
extern long addtoList(long long val);
|
||||
extern void build_frequencies2_list();
|
||||
extern void qso_movFreq(Fl_Widget* w, void*);
|
||||
extern int cb_qso_opMODE();
|
||||
|
|
|
|||
|
|
@ -194,37 +194,39 @@ void updateSelect()
|
|||
{
|
||||
if (freqlist.empty())
|
||||
return;
|
||||
qso_opBrowser->clear(); // Prevent the list from doubling in size on each reload.
|
||||
for (size_t i = 0; i < freqlist.size(); i++) {
|
||||
qso_opBrowser->add(freqlist[i].str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
size_t updateList(unsigned long long rf, int freq, std::string rmd, trx_mode md, std::string usage = "")
|
||||
long updateList(unsigned long long rf, int freq, std::string rmd, trx_mode md, std::string usage = "")
|
||||
{
|
||||
qrg_mode_t m;
|
||||
size_t index = 0;
|
||||
|
||||
m.rmode = rmd;
|
||||
m.mode = md;
|
||||
m.rfcarrier = rf;
|
||||
m.carrier = freq;
|
||||
m.usage = usage;
|
||||
|
||||
for(index = 0; index < freqlist.size(); index++) {
|
||||
if (freqlist[index] == m) return -1;
|
||||
}
|
||||
|
||||
freqlist.push_back(m);
|
||||
sort(freqlist.begin(), freqlist.end());
|
||||
|
||||
std::vector<qrg_mode_t>::const_iterator pos = find(freqlist.begin(), freqlist.end(), m);
|
||||
if (pos != freqlist.end())
|
||||
return pos - freqlist.begin();
|
||||
else
|
||||
return 0;
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
size_t addtoList(unsigned long long val)
|
||||
long addtoList(unsigned long long val)
|
||||
{
|
||||
qrg_mode_t m;
|
||||
|
||||
m.rfcarrier = val;
|
||||
|
||||
Fl::lock();
|
||||
if (strlen(qso_opMODE->value()))
|
||||
m.rmode = qso_opMODE->value();
|
||||
|
||||
|
|
@ -232,6 +234,7 @@ size_t addtoList(unsigned long long val)
|
|||
m.carrier = active_modem->get_freq();
|
||||
m.mode = active_modem->get_mode();
|
||||
}
|
||||
Fl::unlock();
|
||||
return updateList(val, m.carrier, m.rmode, m.mode);
|
||||
}
|
||||
|
||||
|
|
@ -263,6 +266,7 @@ bool readFreqList(bool bdef)
|
|||
is >> m;
|
||||
freqlist.push_back(m);
|
||||
}
|
||||
|
||||
sort(freqlist.begin(), freqlist.end());
|
||||
updateSelect();
|
||||
|
||||
|
|
@ -270,7 +274,8 @@ bool readFreqList(bool bdef)
|
|||
|
||||
progStatus.default_frequencies_filename = fl_filename_name(fname.c_str());
|
||||
|
||||
return freqlist.size();
|
||||
if(freqlist.size()) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void saveFreqList(bool bdef)
|
||||
|
|
@ -331,6 +336,7 @@ void build_frequencies2_list()
|
|||
}
|
||||
}
|
||||
fwidths[max_mode] += (int)ceil(fl_width(mode_info[mmax].sname));
|
||||
qso_opBrowser->column_widths(fwidths);
|
||||
|
||||
if (readFreqList())
|
||||
return;
|
||||
|
|
@ -532,11 +538,14 @@ void qso_delFreq()
|
|||
|
||||
void qso_addFreq()
|
||||
{
|
||||
Fl::lock();
|
||||
unsigned long long freq = qsoFreqDisp->value();
|
||||
if (freq) {
|
||||
size_t pos = addtoList(freq);
|
||||
qso_opBrowser->insert(pos+1, freqlist[pos].str().c_str());
|
||||
long pos = addtoList(freq);
|
||||
if(pos > -1)
|
||||
updateSelect();
|
||||
}
|
||||
Fl::unlock();
|
||||
}
|
||||
|
||||
void qso_updateEntry(int i, std::string usage)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue