view example/regex_mas/ppe/Exec.cc @ 1610:da6835e6d306 draft

fix regex_mas
author Masa <e085726@ie.u-ryukyu.ac.jp>
date Tue, 30 Apr 2013 18:38:32 +0900
parents e6855e99bdde
children 0003782eaec9
line wrap: on
line source

#include <stdio.h>
#include <string.h>
#include "Exec.h"
#include "Func.h"
void line_print(int,int,char*);
#define BUFFER_SIZE 4096

/* これは必須 */
SchedDefineTask(Exec);

static int
run(SchedTask *s, void *rbuf, void *wbuf)
{
    char *i_data = (char *)rbuf;
    unsigned long long *o_data = (unsigned long long*)wbuf;
    unsigned long long *head_tail_flag = o_data +2;
    int length = (int)s->get_inputSize(0);
    int *offset = (int*)s->get_param(1);
    printf("offset = %d\n",offset);
    int word_num = 0;
    int line_num = 1;
    int i = 0;
    bool word_head_a_flag = false; 
    bool a_flag = 0;
    bool match_flag = 0;
    char line_data[BUFFER_SIZE];
    int line_length = 0;
    
    for (; i < length; i++) {
        if (i_data[i] == 0x0A) {
	  
            if (match_flag == true) {
                
            }
            match_flag = false;
            line_length = 0;
            line_num++;
        } else {
            line_data[line_length] = i_data[i];
            line_length++;
              if (i_data[i] == 0x61) {
                  a_flag = true;
              }else if ((i_data[i] == 0x62) && (a_flag == true)) {
                  match_flag = true;
              }else if (i_data[i] == 0x20) {
                  a_flag = false;
              }
        }
    }
   
    head_tail_flag[1] = (word_head_a_flag == true);

    return 0;
}

void line_print(int _line_num,int _line_length,char *input_data){

    printf("%d : ",_line_num);
    for (int k = 0; k < _line_length; k++) {
        printf("%c",input_data[k]);
    }
    printf("\n");
}