~ubuntu-branches/ubuntu/trusty/cctools/trusty-proposed

« back to all changes in this revision

Viewing changes to ftsh/src/variable.c

  • Committer: Package Import Robot
  • Author(s): Michael Hanke
  • Date: 2012-06-15 08:30:02 UTC
  • mfrom: (9.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20120615083002-r5nq7iowcv6bm35n
Tags: 3.5.0-1
* New upstream release.
* Remove obsolete patches 'missing_cflags' and 'python_compat'. They have
  been merged upstream.
* Remove DM-upload flag, not needed anymore.
* Bumped Standards-version to 3.9.3, no changes necessary.
* Do not install the new 'apps' binaries. They carry language-specific
  filename extensions, and upstream was asked if renaming is possible. Until
  this is decided they won't be installed to avoid changing the API twice.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
See the file COPYING for details.
6
6
*/
7
7
 
8
 
#include "xmalloc.h"
 
8
#include "xxmalloc.h"
9
9
#include "buffer.h"
10
10
#include "ftsh_error.h"
11
11
#include "list.h"
115
115
        char *result=0;
116
116
        int i;
117
117
 
118
 
        result = xstrdup("");
 
118
        result = xxstrdup("");
119
119
 
120
120
        for(i=1;i<head->argc;i++) {
121
 
                result = string_combine(result,xstrdup(head->argv[i]));
 
121
                result = string_combine(result,xxstrdup(head->argv[i]));
122
122
                if(i!=(head->argc-1)) {
123
123
                        if(withquotes) {
124
 
                                result = string_combine(result,xstrdup("\" \""));
 
124
                                result = string_combine(result,xxstrdup("\" \""));
125
125
                        } else {
126
 
                                result = string_combine(result,xstrdup(" "));
 
126
                                result = string_combine(result,xxstrdup(" "));
127
127
                        }
128
128
                }
129
129
        }
138
138
 
139
139
        if(!strcmp(name,"$")) {
140
140
                sprintf(buffer,"%d",(int)getpid());
141
 
                return xstrdup(buffer);
 
141
                return xxstrdup(buffer);
142
142
        } else if(!strcmp(name,"#")) {
143
143
                sprintf(buffer,"%d",head->argc-1);
144
 
                return xstrdup(buffer);
 
144
                return xxstrdup(buffer);
145
145
        } else if(!strcmp(name,"@")) {
146
146
                return variable_print_argv(withquotes);
147
147
        } else if(!strcmp(name,"*")) {
148
148
                return variable_print_argv(0);
149
149
        } else if( sscanf(name,"%d",&arg)==1 ) {
150
150
                if(arg>=head->argc) {
151
 
                        return xstrdup("");
 
151
                        return xxstrdup("");
152
152
                } else {
153
 
                        return xstrdup(head->argv[arg]);
 
153
                        return xxstrdup(head->argv[arg]);
154
154
                }
155
155
        } else if( isvalid(name) ) {
156
156
                char *result = getenv(name);
157
 
                if(result) return xstrdup(result);
 
157
                if(result) return xxstrdup(result);
158
158
                result = buffer_load(name);
159
159
                if(result) string_chomp(result);
160
160
                return result;
239
239
                *end = oldend;
240
240
 
241
241
                if(!subvalue) {
242
 
                        subvalue = xstrdup("");
 
242
                        subvalue = xxstrdup("");
243
243
                }
244
244
 
245
245
                length = strlen(value) - (end-dollar) + strlen(subvalue) + 1;