~epr/arb/trunk2

« back to all changes in this revision

Viewing changes to ARB_GDE/GDE_event.cxx

  • Committer: westram
  • Date: 2018-07-10 14:48:45 UTC
  • Revision ID: svn-v4:129cd134-2152-0410-ab65-f3f895bafe68:trunk:17178

  * reintegrates 'gcc' into 'trunk'
    - complete arb port to gcc 8.1 
    - fixes NDEBUG-related issues (not handled by [16986])
  * adds: log:branches/gcc@17164:17177

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
#include <aw_msg.hxx>
10
10
#include <aw_file.hxx>
11
11
#include <arb_progress.h>
 
12
#include <arb_strbuf.h>
12
13
#include <AP_filter.hxx>
13
14
 
14
15
#include <set>
113
114
 
114
115
    set<string>warned_about;
115
116
    int conversion_warning = 0;
116
 
    
 
117
 
 
118
    const int symLen = strlen(symbol);
 
119
    int       actlen = strlen(Action);
 
120
 
117
121
    for (int i, j = 0; (i=Find2(Action+j, symbol)) != -1;) {
118
122
        i += j;
119
123
        ++j;
120
124
        if (i>0 && Action[i-1] == '$') {
121
125
            const char *replaceBy = textvalue;
122
 
            int         skip      = 1;
 
126
            int         skip      = 1; // skip '$'
123
127
 
124
128
            if (i>1 && Action[i-2] == '!') { // use label (if available)
125
129
                if (labelvalue) {
126
130
                    replaceBy = labelvalue;
127
 
                    skip = 2; // skip '!'
 
131
                    skip = 2; // skip '!$'
128
132
                }
129
133
                else {
130
134
                    aw_message(GBS_global_string("[ARB_GDE]: Cannot access label of '%s'\n", symbol));
132
136
                }
133
137
            }
134
138
 
135
 
            int   repLen = strlen(replaceBy);
136
 
            int   symLen = strlen(symbol);
137
 
            int   newlen = strlen(Action)-skip-symLen+repLen+1;
138
 
            char *temp   = ARB_calloc<char>(newlen);
139
 
 
140
 
            strncat(temp, Action, i-skip);
141
 
            strncat(temp, replaceBy, repLen);
142
 
            strcat(temp, &(Action[i+symLen]));
143
 
            freeset(Action, temp);
 
139
            int repLen = strlen(replaceBy);
 
140
            int remLen = skip+symLen;
 
141
 
 
142
            GBS_strstruct temp(actlen-remLen+repLen+1);
 
143
 
 
144
            temp.ncat(Action, i-skip);
 
145
            temp.ncat(replaceBy, repLen);
 
146
            temp.cat(Action+i+symLen);
 
147
 
 
148
            actlen = temp.get_position();
 
149
            freeset(Action, temp.release());
144
150
        }
145
151
        else {
146
152
            if (warned_about.find(symbol) == warned_about.end()) {
163
169
    return Action;
164
170
}
165
171
 
166
 
static char *ReplaceFile(char *Action, GfileFormat file) {
167
 
    char *symbol, *method, *temp;
168
 
    int i, newlen;
169
 
    symbol = file.symbol;
170
 
    method = file.name;
171
 
 
172
 
    for (; (i=Find2(Action, symbol)) != -1;) {
173
 
        newlen  = strlen(Action)-strlen(symbol) + strlen(method)+1;
174
 
        ARB_calloc(temp, newlen);
175
 
        strncat(temp, Action, i);
176
 
        strncat(temp, method, strlen(method));
177
 
        strcat(temp, &(Action[i+strlen(symbol)]));
178
 
        freeset(Action, temp);
 
172
static void ReplaceString(char*& Action, const char *olds, const char *news) {
 
173
    size_t oldslen = strlen(olds);
 
174
    size_t newslen = strlen(news);
 
175
    size_t actlen  = strlen(Action);
 
176
 
 
177
    int i;
 
178
    for (; (i=Find2(Action, olds)) != -1;) {
 
179
        GBS_strstruct temp(actlen-oldslen+newslen+1);
 
180
 
 
181
        temp.ncat(Action, i);
 
182
        temp.ncat(news, newslen);
 
183
        temp.cat(Action+i+oldslen);
 
184
 
 
185
        actlen = temp.get_position();
 
186
        freeset(Action, temp.release());
179
187
    }
180
 
    return Action;
181
188
}
182
189
 
183
 
static char *ReplaceString(char *Action, const char *old, const char *news) {
184
 
    const char *symbol;
185
 
    const char *method;
186
 
    char *temp;
187
 
    int i, newlen;
188
 
 
189
 
    symbol = old;
190
 
    method = news;
191
 
 
192
 
    for (; (i=Find2(Action, symbol)) != -1;) {
193
 
        newlen = strlen(Action)-strlen(symbol) + strlen(method)+1;
194
 
        ARB_calloc(temp, newlen);
195
 
        strncat(temp, Action, i);
196
 
        strncat(temp, method, strlen(method));
197
 
        strcat(temp, &(Action[i+strlen(symbol)]));
198
 
        freeset(Action, temp);
199
 
    }
200
 
    return Action;
 
190
static void ReplaceFile(char*& Action, GfileFormat file) {
 
191
    ReplaceString(Action, file.symbol, file.name);
201
192
}
202
193
 
203
194
static void GDE_freesequ(NA_Sequence *sequ) {
679
670
            if (!changed) break;
680
671
        }
681
672
 
682
 
        for(int j=0; j<current_item->numinputs;  j++) Action = ReplaceFile(Action, current_item->input[j]);
683
 
        for(int j=0; j<current_item->numoutputs; j++) Action = ReplaceFile(Action, current_item->output[j]);
 
673
        for (int j=0; j<current_item->numinputs;  j++) ReplaceFile(Action, current_item->input[j]);
 
674
        for (int j=0; j<current_item->numoutputs; j++) ReplaceFile(Action, current_item->output[j]);
684
675
 
685
676
        if (Find(Action, "$FILTER") == true) {
686
677
            char *filter_name = AWT_get_combined_filter_name(aw_root, AWAR_PREFIX_GDE_TEMP);
687
 
            Action            = ReplaceString(Action, "$FILTER", filter_name);
 
678
            ReplaceString(Action, "$FILTER", filter_name);
688
679
            free(filter_name);
689
680
        }
690
681