OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_52/] [or1ksim/] [support/] [simprintf.c] - Diff between revs 7 and 44

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 7 Rev 44
Line 68... Line 68...
#else
#else
                argaddr = 3;
                argaddr = 3;
#endif
#endif
                debug("simprintf: %s", fmtstrpart);
                debug("simprintf: %s", fmtstrpart);
                while(strlen(fmtstrpart)) {
                while(strlen(fmtstrpart)) {
 
                        debug("simprintf(): 1");
                        if ((fmtstrend = strstr(fmtstrpart + 1, "%")))
                        if ((fmtstrend = strstr(fmtstrpart + 1, "%")))
                                *fmtstrend = '\0';
                                *fmtstrend = '\0';
 
                        debug(" 2");
                        if (strstr(fmtstrpart, "%")) {
                        if (strstr(fmtstrpart, "%")) {
 
                                debug(" 3");
#if STACK_ARGS
#if STACK_ARGS
                                argaddr += 4;
                                argaddr += 4;
                                arg = eval_mem32(argaddr);
                                arg = eval_mem32(argaddr);
#else
#else
                                sprintf(regstr, "r%u", ++argaddr);
                                sprintf(regstr, "r%u", ++argaddr);
                                arg = eval_reg(regstr);
                                arg = eval_reg(regstr);
#endif
#endif
 
                                debug(" 4: fmtstrpart=%p fmtstrpart=%s arg=%p", fmtstrpart, fmtstrpart, arg);
 
                                if (strncmp(fmtstrpart, "%s", 2) == 0) {
 
                                        int len = 0;
 
                                        char *str;
 
                                        for(; eval_mem8(arg++); len++);
 
                                        len++;  /* for null char */
 
                                        arg -= len;
 
                                        str = (char *)malloc(len);
 
                                        len = 0;
 
                                        for(; eval_mem8(arg); len++)
 
                                                *(str+len) = eval_mem8(arg++);
 
                                        *(str+len) = eval_mem8(arg); /* null ch */
 
                                        /* debug("4a: len=%d str=%s\n", len, str);
 
                                        debug("4b:"); */
 
                                        fprintf(f, fmtstrpart, str);
 
                                        free(str);
 
                                } else
                                fprintf(f, fmtstrpart, arg);
                                fprintf(f, fmtstrpart, arg);
                                debug(fmtstrpart, arg);
 
                        } else {
                        } else {
 
                                debug(" 5");
                                fprintf(f, fmtstrpart);
                                fprintf(f, fmtstrpart);
                                debug(fmtstrpart);
                                debug(fmtstrpart);
                        }
                        }
                        if (!fmtstrend)
                        if (!fmtstrend)
                                break;
                                break;
 
                        debug(" 6");
                        fmtstrpart = fmtstrend;
                        fmtstrpart = fmtstrend;
                        *fmtstrpart = '%';
                        *fmtstrpart = '%';
 
                        debug(" 7");
                }
                }
 
 
 
                debug(" 8");
                if (fclose(f))
                if (fclose(f))
                        perror(strerror(errno));
                        perror(strerror(errno));
        }
        }
        else
        else
                perror(strerror(errno));
                perror(strerror(errno));

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.