Exemplo n.º 1
0
 inline lstring directory::folders(const string &pathname, const string &pattern) {
   lstring list;
   string path = pathname;
   path.transform("/", "\\");
   if(!strend(path, "\\")) path.append("\\");
   path.append("*");
   HANDLE handle;
   WIN32_FIND_DATA data;
   handle = FindFirstFile(utf16_t(path), &data);
   if(handle != INVALID_HANDLE_VALUE) {
     if(wcscmp(data.cFileName, L".") && wcscmp(data.cFileName, L"..")) {
       if(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
         string name = (const char*)utf8_t(data.cFileName);
         if(wildcard(name, pattern)) list.append(name);
       }
     }
     while(FindNextFile(handle, &data) != false) {
       if(wcscmp(data.cFileName, L".") && wcscmp(data.cFileName, L"..")) {
         if(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
           string name = (const char*)utf8_t(data.cFileName);
           if(wildcard(name, pattern)) list.append(name);
         }
       }
     }
     FindClose(handle);
   }
   if(list.size() > 0) list.sort();
   for(auto &name : list) name.append("/");  //must append after sorting
   return list;
 }
Exemplo n.º 2
0
 inline lstring directory::files(const string &pathname, const string &pattern) {
   lstring list;
   string path = pathname;
   path.transform("/", "\\");
   if(!strend(path, "\\")) path.append("\\");
   path.append("*");
   HANDLE handle;
   WIN32_FIND_DATA data;
   handle = FindFirstFile(utf16_t(path), &data);
   if(handle != INVALID_HANDLE_VALUE) {
     if((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
       string name = utf8_t(data.cFileName);
       if(wildcard(name, pattern)) list.append(name);
     }
     while(FindNextFile(handle, &data) != false) {
       if((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
         string name = utf8_t(data.cFileName);
         if(wildcard(name, pattern)) list.append(name);
       }
     }
     FindClose(handle);
   }
   if(list.size() > 0) sort(&list[0], list.size());
   return list;
 }
Exemplo n.º 3
0
    static char *
match_config_entry( char *entry )
{
    if (( remote_cn != NULL ) && wildcard( entry, remote_cn, 0 )) {
	return( remote_cn );
    } else if ( wildcard( entry, remote_host, 0 )) {
	return( remote_host );
    } else if ( wildcard( entry, remote_addr, 1 )) {
	return( remote_addr );
    }

    return( NULL );
}
Exemplo n.º 4
0
BOOL IllegalWindowSpec::match(HWND window)
{
//## begin AutoFunction::Match%-160473114.body preserve=yes
	
	if ( !::IsWindow( window ) ) {
		return FALSE ;
	} else {
		BOOL match = TRUE ;
		BOOL checkedSomething = FALSE ;

		if (m_title.length()) {
			checkedSomething = TRUE ;
			char title[256] ;
			::GetWindowText(window, title, 256) ;
			string Title( title ) ;
			if (!(wildcard(m_title, Title, (m_caseSensitive ? FNM_BASHSTYLE | FNM_NOESCAPE : FNM_BASHSTYLE | FNM_CASEFOLD | FNM_NOESCAPE) ))) {
				match = FALSE ;
			}
		}

		if (m_winClass.length()) {
			checkedSomething = TRUE ;
			char winclass[256] ;
			::GetClassName(window, winclass, 256 ) ;
			string Class(winclass) ;
			if (!(wildcard(m_winClass, Class, (m_caseSensitive ? FNM_BASHSTYLE | FNM_NOESCAPE : FNM_BASHSTYLE | FNM_CASEFOLD | FNM_NOESCAPE) ))) {
				match = FALSE ;
			}
		}

		if (m_filename.length()) {
			checkedSomething = TRUE ;
			char file[256] ;

			GetWindowFileName(window, file, 256);

			string File(file) ;
			if (!(wildcard(m_filename, File, (m_caseSensitive ? FNM_BASHSTYLE | FNM_NOESCAPE : FNM_BASHSTYLE | FNM_CASEFOLD | FNM_NOESCAPE) ))) {
				match = FALSE ;
			}
		}

		if ( !checkedSomething ) {
			match = FALSE ;
		}
		
		return match ;
	}
}
Exemplo n.º 5
0
int findfirst(const signed char *pathname, struct ffblk *ffblk, int attrib) {
	signed char *match=strdup(pathname);
	unsigned int i;
	if(match[0]=='*') match++;
	for(i=0;i<strlen(match);i++) { 
		if(match[i]>='a' && match[i]<='z') match[i]^=32; 
	}
	dirsize=0;
	printf("Looking for '%s' (%s)\n",match,pathname);
	int fd = sceIoDopen(path);
	SceIoDirent entry;
	while (sceIoDread(fd, &entry) > 0) {
		if(strcasestr(entry.d_name,match)==0 && wildcard(entry.d_name,match)==0) continue;
		if(dirsize==0) {
			dirfname=(signed char **)calloc(sizeof(signed char *),64);
		} else if((dirsize%64)==0) {
			dirfname=(signed char **)realloc(dirfname,sizeof(signed char *)*(dirsize+64));
		}
		dirfname[dirsize++]=strdup(entry.d_name);
	}
	sceIoDclose(fd);
	printf("Got %d matches\n",dirsize);
	if (dirsize>0) {
		dirpos=1;
		strcpy(ffblk->ff_name,dirfname[dirsize-1]);
		return 0;
	}

	return 1;

}
Exemplo n.º 6
0
static void proc_wild_disp()
{
   DispInArea();
   ggg.wild_page = 0;
   wildcard();
   disp_selection(0);
}
Exemplo n.º 7
0
int wildcard(char *str, char *p)
{
	while(*str) {
		switch(*p) {
			case '*':
				while(*++p == '*');
				if(!*p)
					return true;
				while(*str) {
					printf("str = %c, p = %c\n", *str, *p);
					//if(wildcard(p, str++) == true) {
					if(wildcard(str++, p) == true) {
						return true;
					}
				}
				return false;
			default:
				if(*str != *p)
					return false;
				break;
		}
		str++;
		p++;
	}

	while(*p == '*')
		p++;
	return !*p;
}
Exemplo n.º 8
0
boost::regex convertToRegex( const std::string& stringWithShellLikeWildcard )
{
    std::string wildcard( stringWithShellLikeWildcard );
    boost::replace_all( wildcard, ".", "\\." );
    boost::replace_all( wildcard, "*", ".*" );
    boost::replace_all( wildcard, "/", "\\/" );
    return boost::regex( "^" + wildcard + "$" );
}
Exemplo n.º 9
0
/*
** readfiles() read files.
*/
static void readfiles (int protocol, char *fname)
{
    if (protocol == ASCII)
    {
        wildcard(typefile, fname);
    }
    else if (protocol != TODISK) 
    {
        usingWCprotocol = protocol;
        wildcard(download, fname);
        usingWCprotocol = ASCII;
    }
    else
    {
        mPrintf("Can't journal files!\n ");
    }
}
Exemplo n.º 10
0
int main(void)
{
	if(wildcard("hereheroherr", "*hero*"))
		printf("True\n");
	else
		printf("False\n");

	return 0;
}
Exemplo n.º 11
0
int main()
{
    char *string = "hereheroherr";
    char *pattern = "*hero*";

    if (wildcard(string, pattern) == TRUE)
    {
        printf("\nMatch Found!\n");
    } else {
        printf("\nMatch not Found!\n");
    }
    return 0;
}
Exemplo n.º 12
0
/** Return a string with all help entries that match a pattern */
static char *
list_matching_entries(char *pattern, help_file *help_dat, const char *sep)
{
  static char buff[BUFFER_LEN];
  int offset;
  char *bp;
  size_t n;
  int len;

  bp = buff;

  if (help_dat->admin)
    offset = 1;                 /* To skip the leading & */
  else
    offset = 0;

  if (!wildcard(pattern)) {
    /* Quick way out, use the other kind of matching */
    char the_topic[LINE_SIZE + 2];
    help_indx *entry = NULL;
    strcpy(the_topic, normalize_entry(help_dat, pattern));
    if (!help_dat->indx || help_dat->entries == 0)
      return T("#-1 NO INDEX FOR FILE");
    entry = help_find_entry(help_dat, the_topic);
    if (!entry)
      return (char *) "";
    return (char *) (entry->topic + offset);
  }

  bp = buff;

  if (sep)
    len = strlen(sep);

  for (n = 0; n < help_dat->entries; n++)
    if (quick_wild(pattern, help_dat->indx[n].topic + offset)) {
      safe_str(help_dat->indx[n].topic + offset, buff, &bp);
      if (sep)
        safe_strl(sep, len, buff, &bp);
    }

  if (bp > buff)
    *(bp - len) = '\0';
  else {
    *bp = '\0';
  }

  return buff;
}
Exemplo n.º 13
0
int match(char *ausdruck, char *text) {
   if(ausdruck[0] == '\0')
      return 1;
#ifdef __unix__
   if(ausdruck[1] == '*')
#elif __WIN32__
   if(ausdruck[1] == '~')
#endif
      return wildcard(ausdruck[0], ausdruck+2, text);
   if(ausdruck[0] == '$' && ausdruck[1] == '\0')
      return *text == '\0';
   if(*text != '\0' && ( ausdruck[0] == '.' ||
     ausdruck[0] == *text))
      return match(ausdruck+1, text+1);
   return 0;
}
Exemplo n.º 14
0
void DIALOG_DRC_CONTROL::OnButtonBrowseRptFileClick( wxCommandEvent& event )
{
    wxFileName fn;
    wxString   wildcard( _( "DRC report files (.rpt)|*.rpt" ) );
    wxString   Ext( wxT( "rpt" ) );

    fn = m_Parent->GetBoard()->GetFileName() + wxT( "-drc" );
    fn.SetExt( Ext );

    wxFileDialog dlg( this, _( "Save DRC Report File" ), wxEmptyString,
                      fn.GetFullName(), wildcard,
                      wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxFD_CHANGE_DIR );

    if( dlg.ShowModal() == wxID_CANCEL )
        return;

    m_RptFilenameCtrl->SetValue( dlg.GetPath() );
}
Exemplo n.º 15
0
 inline lstring directory::files(const string &pathname, const string &pattern) {
   lstring list;
   DIR *dp;
   struct dirent *ep;
   dp = opendir(pathname);
   if(dp) {
     while(ep = readdir(dp)) {
       if(!strcmp(ep->d_name, ".")) continue;
       if(!strcmp(ep->d_name, "..")) continue;
       if((ep->d_type & DT_DIR) == 0) {
         if(wildcard(ep->d_name, pattern)) list.append(ep->d_name);
       }
     }
     closedir(dp);
   }
   if(list.size() > 0) sort(&list[0], list.size());
   return list;
 }
Exemplo n.º 16
0
 inline lstring directory::folders(const string &pathname, const string &pattern) {
   lstring list;
   DIR *dp;
   struct dirent *ep;
   dp = opendir(pathname);
   if(dp) {
     while(ep = readdir(dp)) {
       if(!strcmp(ep->d_name, ".")) continue;
       if(!strcmp(ep->d_name, "..")) continue;
       if(ep->d_type & DT_DIR) {
         if(wildcard(ep->d_name, pattern)) list.append(ep->d_name);
       }
     }
     closedir(dp);
   }
   if(list.size() > 0) list.sort();
   for(auto &name : list) name.append("/");  //must append after sorting
   return list;
 }
Exemplo n.º 17
0
void ecRunTestsExecutablesDialog::OnAdd(wxCommandEvent& event)
{
    wxCheckListBox* checkList = (wxCheckListBox*) FindWindow(ecID_RUN_TESTS_TEST_LIST);
    if (!checkList)
        return;

//#ifdef __WXMSW__
//    wxString wildcard(wxT("Executables (*.exe)|*.exe"));
//#else
    wxString wildcard(wxT("Executables (*)|*"));
//#endif

    wxFileDialog dialog(this, _("Choose one or more executables to add"), wxGetCwd(), wxEmptyString,
        wildcard, wxMULTIPLE|wxOPEN);

    if (dialog.ShowModal() == wxID_OK)
    {
        wxArrayString paths;
        dialog.GetPaths(paths);

        bool err = FALSE;

        unsigned int i;
        int n = paths.Count();
        for (i = 0; i < n; i++)
        {
            // TODO: check that it's the right kind of file
            if (-1 == checkList->FindString(paths[i]))
            {
                checkList->Append(paths[i]);
                checkList->Check(checkList->Number()-1, TRUE);
            }
            else
                err = TRUE;
        }
        if (err)
            wxMessageBox(_("One or more of the files was already present"),
                wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK, this);
    }
}
Exemplo n.º 18
0
	int LuaProgressSink::LuaDisplaySaveDialog(lua_State *L)
	{
		ProgressSink *ps = GetObjPointer(L, lua_upvalueindex(1));
		wxString message(check_wxstring(L, 1));
		wxString dir(check_wxstring(L, 2));
		wxString file(check_wxstring(L, 3));
		wxString wildcard(check_wxstring(L, 4));
		bool prompt_overwrite = !lua_toboolean(L, 5);

		int flags = wxFD_SAVE;
		if (prompt_overwrite)
			flags |= wxFD_OVERWRITE_PROMPT;

		wxFileDialog diag(ps->GetParentWindow(), message, dir, file, wildcard, flags);
		if (ps->ShowDialog(&diag) == wxID_CANCEL) {
			lua_pushnil(L);
			return 1;
		}

		lua_pushstring(L, diag.GetFilename().utf8_str());
		return 1;
	}
Exemplo n.º 19
0
	int LuaProgressSink::LuaDisplayOpenDialog(lua_State *L)
	{
		ProgressSink *ps = GetObjPointer(L, lua_upvalueindex(1));
		wxString message(check_wxstring(L, 1));
		wxString dir(check_wxstring(L, 2));
		wxString file(check_wxstring(L, 3));
		wxString wildcard(check_wxstring(L, 4));
		bool multiple = !!lua_toboolean(L, 5);
		bool must_exist = lua_toboolean(L, 6) || lua_isnil(L, 6);

		int flags = wxFD_OPEN;
		if (multiple)
			flags |= wxFD_MULTIPLE;
		if (must_exist)
			flags |= wxFD_FILE_MUST_EXIST;

		wxFileDialog diag(0, message, dir, file, wildcard, flags);
		if (ps->ShowDialog(&diag) == wxID_CANCEL) {
			lua_pushnil(L);
			return 1;
		}

		if (multiple) {
			wxArrayString files;
			diag.GetFilenames(files);

			lua_newtable(L);
			for (size_t i = 0; i < files.size(); ++i) {
				lua_pushstring(L, files[i].utf8_str());
				lua_rawseti(L, -2, i + 1);
			}

			return 1;
		}

		lua_pushstring(L, diag.GetFilename().utf8_str());
		return 1;
	}
Exemplo n.º 20
0
int wildcard(char *string, char *pattern)
{
    while(*string)
    {
        switch(*pattern)
        {
            case '*': do {++pattern;}while(*pattern == '*');
                      if(!*pattern) return (TRUE);
                      while (*string) {
                            if(wildcard(pattern, string++)==TRUE)
                                return TRUE;
                      }
                      return FALSE;
            default : if(*string != *pattern) return (FALSE);
                      break;
        }
        ++pattern;
        ++string;
    }

    while(*pattern == '*') ++pattern;
    return !*pattern;
}
Exemplo n.º 21
0
void EDA_BASE_FRAME::OnSelectPreferredEditor( wxCommandEvent& event )
{
    wxFileName  fn = Pgm().GetEditorName();
    wxString    wildcard( wxT( "*" ) );

#ifdef __WINDOWS__
    wildcard += wxT( ".exe" );
#endif

    wildcard.Printf( _( "Executable file (%s)|%s" ),
                     GetChars( wildcard ), GetChars( wildcard ) );

    wxFileDialog dlg( this, _( "Select Preferred Editor" ), fn.GetPath(),
                      fn.GetFullName(), wildcard,
                      wxFD_OPEN | wxFD_FILE_MUST_EXIST );

    if( dlg.ShowModal() == wxID_CANCEL )
        return;

    wxString editor = dlg.GetPath();

    Pgm().SetEditorName( editor );
}
Exemplo n.º 22
0
/*
** readdir() read the directory.
*/
static void readdir (char *fname)
{
    int printdir();
    long sectors, bytes;

    FDSectCount = 0L;
    if (FDextended)
        tagSetup();

    doCR();
    wildcard(printdir, strlen(fname) ? fname : "*.*");
    if (FDextended)
        tagClose();

    mPrintf("\n %s total.\n ", plural("byte", FDSectCount));
    if (onConsole || cfg.diskusage) 
    {
        diskSpaceLeft(roomBuf.rbdirname, &sectors, &bytes);
        mPrintf("%s free in %s\n ", plural("byte", bytes),
            roomBuf.rbdirname);
    }

    FDextended = NO;
}
Exemplo n.º 23
0
void FTSSpec::scoreDocument( const BSONObj& obj,
                             const FTSLanguage& parentLanguage,
                             const string& parentPath,
                             bool isArray,
                             TermFrequencyMap* term_freqs ) const {

    if ( _textIndexVersion == TEXT_INDEX_VERSION_1 ) {
        dassert( parentPath == "" );
        dassert( !isArray );
        return _scoreDocumentV1( obj, term_freqs );
    }

    const FTSLanguage& language = _getLanguageToUseV2( obj, parentLanguage );
    Stemmer stemmer( language );
    Tools tools( language, &stemmer, StopWords::getStopWords( language ) );

    // Perform a depth-first traversal of obj, skipping fields not touched by this spec.
    BSONObjIterator j( obj );
    while ( j.more() ) {

        BSONElement elem = j.next();
        string fieldName = elem.fieldName();

        // Skip "language" specifier fields if wildcard.
        if ( wildcard() && languageOverrideField() == fieldName ) {
            continue;
        }

        // Compose the dotted name of the current field:
        // 1. parent path empty (top level): use the current field name
        // 2. parent path non-empty and obj is an array: use the parent path
        // 3. parent path non-empty and obj is a sub-doc: append field name to parent path
        string dottedName = ( parentPath.empty() ? fieldName
                              : isArray ? parentPath
                              : parentPath + '.' + fieldName );

        // Find lower bound of dottedName in _weights.  lower_bound leaves us at the first
        // weight that could possibly match or be a prefix of dottedName.  And if this
        // element fails to match, then no subsequent weight can match, since the weights
        // are lexicographically ordered.
        Weights::const_iterator i = _weights.lower_bound( elem.type() == Object
                                    ? dottedName + '.'
                                    : dottedName );

        // possibleWeightMatch is set if the weight map contains either a match or some item
        // lexicographically larger than fieldName.  This boolean acts as a guard on
        // dereferences of iterator 'i'.
        bool possibleWeightMatch = ( i != _weights.end() );

        // Optimize away two cases, when not wildcard:
        // 1. lower_bound seeks to end(): no prefix match possible
        // 2. lower_bound seeks to a name which is not a prefix
        if ( !wildcard() ) {
            if ( !possibleWeightMatch ) {
                continue;
            }
            else if ( !_matchPrefix( dottedName, i->first ) ) {
                continue;
            }
        }

        // Is the current field an exact match on a weight?
        bool exactMatch = ( possibleWeightMatch && i->first == dottedName );

        double weight = ( possibleWeightMatch ? i->second : DEFAULT_WEIGHT );

        switch ( elem.type() ) {
        case String:
            // Only index strings on exact match or wildcard.
            if ( exactMatch || wildcard() ) {
                _scoreStringV2( tools, elem.valuestr(), term_freqs, weight );
            }
            break;
        case Object:
            // Only descend into a sub-document on proper prefix or wildcard.  Note that
            // !exactMatch is a sufficient test for proper prefix match, because of
            // matchPrefix() continue block above.
            if ( !exactMatch || wildcard() ) {
                scoreDocument( elem.Obj(), language, dottedName, false, term_freqs );
            }
            break;
        case Array:
            // Only descend into arrays from non-array parents or on wildcard.
            if ( !isArray || wildcard() ) {
                scoreDocument( elem.Obj(), language, dottedName, true, term_freqs );
            }
            break;
        default:
            // Skip over all other BSON types.
            break;
        }
    }
}
Exemplo n.º 24
0
int dcl_type(PARAM_T *p, PARAM_T *q)
{
    PARAM type_param;
    char    vms[MAX_TOKEN];
    char    outfil[MAX_TOKEN];
    char    dos[MAX_TOKEN];
    char    drive[_MAX_DRIVE];
    char    dir[_MAX_DIR];
    char    file[_MAX_FNAME];
    char    ext[_MAX_EXT];
    int     i       = 0;
    int     recurse = 0;
    int     s_recurse = 0;
    int     retcod  = 0;
    int     f_output = 0;
    char    *type_command = "TYPE";

    NEXT_LINE();
    if (cmd[C].subr) return(0);
    if (!dcl[D].cc[dcl[D].ccl]) return(0);
    if (p == NULL || q == NULL) return(DCL_ERROR);

    _STATUS = 0;
    *vms = 0; *outfil = 0; *dos = 0;
    *drive = 0; *dir = 0; *file = 0; *ext = 0;

    type_param.all = 0;
    type_param.confirm = 0;
    type_param.page = 0;
    type_param.wildcard = 0;
    type_param.file_nb = 0;
    type_param.before = -1;
    type_param.since = 0;
    type_param.output = dcl[D].SYS_OUTPUT;
    type_param.ok = 1;
    type_param.numbers = 0;

    retcod = cmd_parse_line(dcl_line,TYPE_PARAM,TYPE_QUAL,p,q);
    if (retcod != DCL_OK) 
        goto exit_label;

    for (i = 0; q[i].tag; i++) {
        if (q[i].flag & PRESENT) 
            switch (q[i].tag) {
                case 1:                                 /* /ALL     */
                    type_param.all = TRUE;
                    break;
                case 2:                                 /* /BEFORE  */
                    if (!*q[i].value) strcpy(q[i].value,"TODAY");
                    tm_str_to_long(q[i].value,&type_param.before);
                    break;
                case 3:                                 /*  /CONFIRM */
                    type_param.confirm = 1;
                    break;
                case 4:                                 /*  /NOCONFIRM */
                    type_param.confirm = 0;
                    break;
                case 5:                                 /*  /PAGE      */
                    type_param.page = 1;
                    break;
                case 6:                                 /*  /OUTPUT    */
                    dcl_string(q[i].value,outfil,MAX_TOKEN);
                    cvfs_vms_to_dos(outfil,dos,&recurse);
                    if (!cvfs_check_device(dos)){
                        _splitpath(dos,drive,dir,file,ext);
                        if (strlen(file) == 0){
                            strcat(dos,"TYPE");
                            }
                        if (strlen(ext) == 0){
                            strcat(dos,".LIS");
                            }
                        }
                    type_param.output = fopen(dos,"at");
                    if (type_param.output == NULL) {
		                (void)dcl_printf(dcl[D].SYS_OUTPUT,"%s: %s\n",outfil,strerror(errno));
                        _SEVERITY = 2;
                        _STATUS = 19;
                        retcod = -1;
                        goto exit_label;
                        }
                    f_output = 1;
                    break;
                case 7:                                 /*  /SINCE  */
                    if (!*q[i].value) strcpy(q[i].value,"TODAY");
                    tm_str_to_long(q[i].value,&type_param.since);
                    break;
                case 8:                                 /*  /SUBDIR */
                    recurse = 1;
                    break;
                case 9:                                /*  /NOSUBDIR */
                    recurse = 0;
                    break;
                case 10:                                /*  /NUMBERS */
                    type_param.numbers = 1;
                    break;
                default:
                    ;
            } /* end switch */
    }   /* end for */

    dcl_string(p[0].value,vms,MAX_TOKEN);

    if (type_param.page && f_output) {
        (void)dcl_printf(dcl[D].SYS_OUTPUT,"/PAGE and /OUTPUT parameters are mutually exclusives.\n");
        _SEVERITY = 2;
        _STATUS = 19;
        retcod = -1;
        goto exit_label;
    }

    if (strncasecmp(vms,"SYS$INPUT",9)) {
        cvfs_lst_to_dos(vms,dos,&s_recurse);
        if (s_recurse) recurse = 1;
        type_param.wildcard = (char)wildcard(dos);
        (void)dcl_searchdirlst(type_command,dos,recurse,dcltype_do_it,&type_param);
        if (type_param.file_nb == 0){
            if (type_param.wildcard)
                (void)dcl_printf(dcl[D].SYS_OUTPUT,"No file found.\n");
            else
                (void)dcl_printf(dcl[D].SYS_OUTPUT,"File not found.\n");
            _SEVERITY = 1;
            _STATUS = 2;
            retcod = -1;
            goto exit_label;
        }
    }
    else {
        (void)dcltype_sysinput(&type_param);
    }
    
exit_label:
    if (f_output)
        fclose(type_param.output);
    if (HARDERR)
        tio_print_interrupt();

    return(retcod);
}
Exemplo n.º 25
0
static int
twhich( char *pattern, int displayall )
{
    struct node		*node;
    struct transcript	*tran;
    extern struct transcript	*tran_head;
    extern struct list	*exclude_list;
    int			cmp = 0, match = 0;

    /* check exclude list */
    if ( exclude_list->l_count > 0 ) {
        for ( node = list_pop_head( exclude_list ); node != NULL;
                node = list_pop_head( exclude_list )) {
            if ( wildcard( node->n_path, pattern, case_sensitive )) {
                printf( "# Exclude\n" );
                printf( "# exclude pattern: %s\n", node->n_path );
                if ( !displayall ) {
                    goto done;
                }
            }
            free( node );
        }
    }

    for ( tran = tran_head; tran->t_next != NULL; tran = tran->t_next ) {

        /* Skip NULL/empty transcripts */
        if ( tran->t_eof ) {
            continue;
        }

        while (( cmp = pathcasecmp( tran->t_pinfo.pi_name,
                                    pattern, case_sensitive )) < 0 ) {
            transcript_parse( tran );
            if ( tran->t_eof ) {
                break;
            }
        }
        if ( tran->t_eof ) {
            continue;
        }

        if ( cmp > 0 ) {
            continue;
        }

        if ( cmp == 0 ) {
            match++;
            switch( tran->t_type ) {
            case T_POSITIVE:
                printf( "# Positive\n" );
                break;

            case T_NEGATIVE:
                printf( "# Negative\n" );
                break;

            case T_SPECIAL:
                printf( "# Special\n" );
                break;

            default:
                fprintf( stderr, "unknown transcript type\n" );
                exit( 2 );
            }
            printf( "# %s:\n", tran->t_kfile );

            if ( tran->t_pinfo.pi_minus ) {
                printf( "%s:\n", tran->t_shortname );
                t_print( NULL, tran, PR_STATUS_MINUS );
            } else {
                t_print( NULL, tran, PR_TRAN_ONLY );
            }

            if ( !displayall ) {
                goto done;
            }
        }
    }

done:
    if ( match ) {
        return( 0 );
    } else {
        return( 1 );
    }
}
Exemplo n.º 26
0
gboolean feedkey_gtab(KeySym key, int kbstate)
{
  int i,j=0;
  int inkey=0;
  char *pselkey= NULL;
  gboolean phrase_selected = FALSE;
  char seltab_phrase[MAX_SELKEY];
  gboolean is_keypad = FALSE;
  gboolean shift_m = (kbstate & ShiftMask) > 0;
//  gboolean ctrl_m = (kbstate & ControlMask) > 0;
  gboolean capslock_on = (kbstate & LockMask);

  bzero(seltab_phrase, sizeof(seltab_phrase));

//  dbg("uuuuu %x %x   shift,ctrl:%d,%d\n", key, kbstate, shift_m, ctrl_m);

  if (!cur_inmd)
    return 0;

  gboolean is_dayi = !strncmp(cur_inmd->filename, "dayi", 4);

  if ((tsin_chinese_english_toggle_key == TSIN_CHINESE_ENGLISH_TOGGLE_KEY_CapsLock) &&
      (key == XK_Caps_Lock)){
    // The CapLock status may be incorrect when XK_Caps_Lock is pressed.
    gboolean new_tsin_pho_mode = ! gdk_keymap_get_caps_lock_state(gdk_keymap_get_default());
    if (current_CS->tsin_pho_mode != new_tsin_pho_mode) {
      current_CS->tsin_pho_mode = new_tsin_pho_mode;
      save_CS_current_to_temp();
      tsin_set_eng_ch(new_tsin_pho_mode);
    }
  }

  if ((kbstate & (Mod1Mask|Mod4Mask|Mod5Mask|ControlMask))==ControlMask
     && key>='1' && key<='9' && ggg.gbufN) {
    save_gtab_buf_phrase(key);
    return 1;
  }

  if (ggg.gbufN && key==XK_Tab)
    return 1;

   if ((key==XK_Shift_L||key==XK_Shift_R) && !key_press_time) {
     key_press_time = current_time();
     key_press_time_ctrl = 0;
   } else
  if ((key==XK_Control_L||key==XK_Control_R) && !key_press_time_ctrl && tss.pre_selN) {
    key_press_time_ctrl = current_time();
    return TRUE;
  } else {
    key_press_time_ctrl = 0;
    key_press_time = 0;
  }

  if (kbstate & (Mod1Mask|Mod4Mask|Mod5Mask|ControlMask)) {
    return 0;
  }

  if (poo.same_pho_query_state == SAME_PHO_QUERY_pho_select)
    return feedkey_pho(key, 0);

  if (poo.same_pho_query_state == SAME_PHO_QUERY_none && gwin_pho &&
    GTK_WIDGET_VISIBLE(gwin_pho))
     hide_win_pho();

  if (!tsin_pho_mode()) {
    if (key < 0x20 || key>=0x7f)
      goto shift_proc;

    if (capslock_on && hime_capslock_lower)
      case_inverse((KeySym *)&key, shift_m);

    if (ggg.gbufN)
      insert_gbuf_cursor_char(key);
    else
      send_ascii(key);

    return 1;
  }


  int lcase;
  lcase = tolower(key);
  int ucase;
  ucase = toupper(key);
  if (key < 127 && cur_inmd->keymap[key]) {
     if (key < 'A' || key > 'z' || (key > 'Z'  && key < 'a') )
       goto shift_proc;
     if (cur_inmd->keymap[lcase] != cur_inmd->keymap[ucase])
       goto next;

  }


shift_proc:
  if (shift_m && !strchr(cur_inmd->selkey, key) && !ggg.more_pg && key>=' ' && key < 0x7e &&
       key!='*' && (key!='?' || (gtab_shift_phrase_key && !ggg.ci))) {
    if (gtab_shift_phrase_key) {
      if (tss.pre_selN && shift_char_proc(key, kbstate))
        return TRUE;
      if (feed_phrase(key, kbstate))
        return TRUE;
    } else {
      if (!cur_inmd->keymap[key] || (lcase != ucase &&
           cur_inmd->keymap[lcase]==cur_inmd->keymap[ucase]))
        return shift_char_proc(key, kbstate);
    }
  }

  gboolean has_wild;
  has_wild = FALSE;

  switch (key) {
    case XK_BackSpace:
      ggg.last_idx=0;
      ggg.spc_pressed=0;
      ggg.sel1st_i=MAX_SELKEY-1;
      clear_gtab_input_error_color();
      hide_gtab_pre_sel();

      if (ggg.ci==0) {
        if (AUTO_SELECT_BY_PHRASE)
          return gtab_buf_backspace();
        else
          return 0;
      }

      if (ggg.ci>0)
        ggg.inch[--ggg.ci]=0;

      if (has_wild_card()) {
        proc_wild_disp();
        return 1;
      }


      ggg.wild_mode=0;
      ggg.invalid_spc = FALSE;
      if (ggg.ci==1 && cur_inmd->use_quick) {
        int i;
        clr_seltab();
        for(i=0;i<cur_inmd->M_DUP_SEL;i++)
          utf8cpy(seltab[i], (char *)cur_inmd->qkeys->quick1[ggg.inch[0]-1][i]);

        ggg.defselN=cur_inmd->M_DUP_SEL;
        DispInArea();
        goto Disp_opt;
      } else
      if (ggg.ci==2 && cur_inmd->use_quick) {
        int i;
        clr_seltab();
        for(i=0;i<cur_inmd->M_DUP_SEL;i++)
          utf8cpy(seltab[i], (char *)cur_inmd->qkeys->quick2[ggg.inch[0]-1][ggg.inch[1]-1][i]);

        ggg.defselN=cur_inmd->M_DUP_SEL;
        DispInArea();
        goto Disp_opt;
      }

      break;
    case XK_KP_Enter:
    case XK_Return:
      if (AUTO_SELECT_BY_PHRASE) {
        hide_gtab_pre_sel();
        if (shift_m) {
          return save_gtab_buf_shift_enter();
        } else
          return output_gbuf();
      }
      else
        return 0;
    case XK_Up:
      if (gtab_has_input())
        return TRUE;
      return FALSE;
    case XK_Down:
    case XK_KP_Down:
      if (AUTO_SELECT_BY_PHRASE)
        return show_buf_select();
      else
        return 0;
    case XK_Escape:
      hide_gtab_pre_sel();
      if (ggg.gtab_buf_select) {
        ggg.gtab_buf_select = 0;
        reset_gtab_all();
        ClrSelArea();
        if (hime_pop_up_win && !gtab_has_input())
          hide_win_gtab();
        return 1;
      }
      ClrSelArea();
      close_gtab_pho_win();
      if (ggg.ci) {
        reset_gtab_all();
        return 1;
      } else {
        if (ggg.gbufN) {
          set_gtab_user_head();
          return 1;
        }
        ClrIn();
        return 0;
      }
    case XK_Prior:
    case XK_KP_Prior:
    case XK_KP_Subtract:
      if (ggg.wild_mode) {
        if (ggg.wild_page >= cur_inmd->M_DUP_SEL) ggg.wild_page-=cur_inmd->M_DUP_SEL;
        wildcard();
        return 1;
      } else
      if (ggg.more_pg) {
        if (ggg.gtab_buf_select) {
          gbuf_prev_pg();
          return 1;
        }

        ggg.pg_idx -= page_len();
        if (ggg.pg_idx < ggg.S1)
          ggg.pg_idx = ggg.S1;

        goto next_pg;
      }

      if (key==XK_KP_Subtract)
        goto keypad_proc;

      return win_sym_page_up();
    case XK_Next:
    case XK_KP_Next:
    case XK_KP_Add:
      if (ggg.more_pg) {
        if (ggg.gtab_buf_select) {
          gbuf_next_pg();
          return 1;
        }
next_page:
//        dbg("more...\n");
        ggg.pg_idx += page_len();
        if (ggg.pg_idx >=ggg.E1)
          ggg.pg_idx = ggg.S1;
        goto next_pg;
      } else {
        if (key==XK_KP_Add)
          goto keypad_proc;
        if (win_sym_page_down())
          return TRUE;
        if (!ggg.gtab_buf_select && ggg.gbufN && AUTO_SELECT_BY_PHRASE)
          return show_buf_select();
        return FALSE;
      }
    case ' ':
      hide_gtab_pre_sel();

      if (ggg.invalid_spc && gtab_invalid_key_in)
        ClrIn();

      if (!gtab_invalid_key_in && ggg.spc_pressed && ggg.invalid_spc) {
        ClrIn();
        return 1;
      }

      has_wild = has_wild_card();

//      dbg("ggg.wild_mode:%d ggg.more_pg:%d ggg.ci:%d  has_wild:%d\n", ggg.wild_mode, ggg.more_pg, ggg.ci, has_wild);

      if (ggg.wild_mode) {
        // request from tetralet
        if (!ggg.wild_page && ggg.total_matchN < cur_inmd->M_DUP_SEL) {
          ggg.sel1st_i = 0;
          goto direct_select;
        }

        ggg.wild_page += cur_inmd->M_DUP_SEL;
        if (ggg.wild_page >= ggg.total_matchN)
          ggg.wild_page=0;

        wildcard();
        ggg.spc_pressed = TRUE;
        return 1;
      } else
      if (ggg.more_pg && !(_gtab_space_auto_first & GTAB_space_auto_first_any)) {
        if (ggg.gtab_buf_select) {
          gbuf_next_pg();
          return 1;
        }
        else
          goto next_page;
      } else
      if (ggg.ci==0) {
        if (current_CS->b_half_full_char)
          return full_char_proc(key);

        if (ggg.gbufN) {
          output_gbuf();
        } else
          return 0;
      } else
      if (!has_wild) {
//        dbg("iii %d  ggg.defselN:%d   %d\n", ggg.sel1st_i, ggg.defselN, cur_inmd->M_DUP_SEL);
        if (_gtab_space_auto_first == GTAB_space_auto_first_any && seltab[0][0] &&
            ggg.sel1st_i==MAX_SELKEY-1) {
          ggg.sel1st_i = 0;
        }

        if (_gtab_space_auto_first == GTAB_space_auto_first_nofull && ggg.exa_match > 1
            && !AUTO_SELECT_BY_PHRASE && gtab_dup_select_bell)
          bell();

        if (seltab[ggg.sel1st_i][0]) {
//          dbg("ggg.last_full %d %d\n", ggg.last_full,ggg.spc_pressed);
          if (gtab_full_space_auto_first || ggg.spc_pressed) {
direct_select:
            if (AUTO_SELECT_BY_PHRASE && poo.same_pho_query_state != SAME_PHO_QUERY_gtab_input) {
//              dbg("ins ggg.kval %x\n", ggg.kval);
              insert_gbuf_cursor1_cond(seltab[ggg.sel1st_i], ggg.kval, ggg.exa_match);
            }
            else
              putstr_inp(seltab[ggg.sel1st_i]);  /* select 1st */
            return 1;
          }
        }
      }

      ggg.last_full=0;
      ggg.spc_pressed=1;
//      dbg("spc_pressed=1\n");

      if (has_wild) {
        ggg.wild_page=0;
        ggg.wild_mode=1;
        wildcard();
        return 1;
      }

      break;
    case '?':
    case '*':
      if ((!gtab_que_wild_card && key == '?') || (!gtab_que_wild_card_asterisk && key == '*')) {
        inkey=cur_inmd->keymap[key];
        if ((inkey && (inkey!=cur_inmd->WILD_QUES && inkey!=cur_inmd->WILD_STAR)) || ptr_selkey(key))
          goto next;
        if (AUTO_SELECT_BY_PHRASE && ggg.gbufN) {
          insert_gbuf_cursor_char(key);
          return 1;
        } else {
          if (current_CS->b_half_full_char)
            return full_char_proc(key);
		  else
            return 0;
		}
      }
      if (tss.pre_selN && shift_char_proc(key, kbstate))
        return TRUE;

      if (current_CS->b_half_full_char)
        return full_char_proc(key);

      inkey=cur_inmd->keymap[key];
      if ((inkey && (inkey!=cur_inmd->WILD_STAR && inkey!=cur_inmd->WILD_QUES)) || ptr_selkey(key)) {
//        dbg("%d %d\n", inkey, cur_inmd->WILD_STAR);
        goto next;
      }
      if (ggg.ci< cur_inmd->MaxPress) {
        ggg.inch[ggg.ci++]=inkey;
        DispInArea();

        if (hime_pop_up_win)
          show_win_gtab();

        ggg.total_matchN = 0;
        ggg.wild_page=0;
        ggg.wild_mode=1;
        wildcard();
        return 1;
      }
      return 0;
    case XK_Left:
    case XK_KP_Left:
      return gbuf_cursor_left();
    case XK_Right:
    case XK_KP_Right:
      return gbuf_cursor_right();
    case XK_Home:
    case XK_KP_Home:
      return gbuf_cursor_home();
    case XK_End:
    case XK_KP_End:
      return gbuf_cursor_end();
    case XK_Delete:
    case XK_KP_Delete:
      return gtab_buf_delete();
    case XK_Shift_L:
    case XK_Shift_R:
    case XK_Control_R:
    case XK_Control_L:
    case XK_Alt_L:
    case XK_Alt_R:
    case XK_Caps_Lock:
      return 0;
    case '`':
      if (gtab_pho_query && !cur_inmd->keymap[key]) {
        poo.same_pho_query_state = SAME_PHO_QUERY_gtab_input;
        reset_gtab_all();
        disp_gtab_sel(_("輸入要查的同音字,接著在注音視窗選字"));
        if (hime_pop_up_win)
          show_win_gtab();
        disp_pho_sel("");
        init_gtab_pho_query_win();
        return 1;
      }
    default:
next:

      if (key < 0x7f)
        inkey= cur_inmd->keymap[key];
      else
        inkey = 0;

      if (shift_m && !inkey && !tss.ctrl_pre_sel &&
        tss.pre_selN && shift_char_proc(key, kbstate))
        return TRUE;

      clear_gtab_input_error_color();

      if (ggg.invalid_spc && gtab_invalid_key_in) {
        ClrIn();
      }
      if (key>=XK_KP_0 && key<=XK_KP_9) {
        if (!ggg.ci) {
          if (ggg.gbufN) {
            insert_gbuf_cursor_char(key - XK_KP_0 + '0');
            return 1;
          } else
            return 0;
        }
        if (is_dayi) {
          key = key - XK_KP_0 + '0';
          is_keypad = TRUE;
        }
      }

      int keypad;
keypad_proc:
      keypad = keypad_proc(key);
      if (keypad) {
        if (!ggg.ci) {
          if (ggg.gbufN) {
            insert_gbuf_cursor_char(keypad);
            return 1;
          } else
            return 0;
        }
      }
      char *pendkey = strchr(cur_inmd->endkey, key);

      pselkey=ptr_selkey(key);

      if (!pselkey && (key < 32 || key > 0x7e) && (gtab_full_space_auto_first || ggg.spc_pressed)) {
//        dbg("%x %x ggg.sel1st_i:%d  '%c'\n", pselkey, key, ggg.sel1st_i, seltab[ggg.sel1st_i][0]);
        if (seltab[ggg.sel1st_i][0]) {
          if (AUTO_SELECT_BY_PHRASE && poo.same_pho_query_state != SAME_PHO_QUERY_gtab_input)
            insert_gbuf_cursor1_cond(seltab[ggg.sel1st_i], ggg.kval, ggg.exa_match);
          else
            putstr_inp(seltab[ggg.sel1st_i]);  /* select 1st */
        }

        return 0;
      }



//        dbg("ggg.spc_pressed %d %d %d is_keypad:%d\n", ggg.spc_pressed, ggg.last_full, cur_inmd->MaxPress, is_keypad);

#if 1 // for dayi, testcase :  6 space keypad6
      int vv = pselkey - cur_inmd->selkey;
      if (pselkey && tss.pre_selN && !ggg.gtab_buf_select && (tss.ctrl_pre_sel||
          ((!inkey||ggg.spc_pressed||is_keypad)&&! gtab_disp_partial_match_on() && !gtab_pre_select_on()))) {
        if (gtab_pre_select_idx(vv))
          return TRUE;
      } else
      if (( (ggg.spc_pressed||ggg.last_full||is_keypad) ||(ggg.wild_mode && (!inkey ||pendkey)) || ggg.gtab_buf_select) && pselkey) {
        if ((_gtab_space_auto_first & GTAB_space_auto_first_any) && !ggg.wild_mode)
          vv++;

        if (vv<0)
          vv=9;

        if (seltab[vv][0]) {
          if (AUTO_SELECT_BY_PHRASE && !same_query_show_pho_win()) {
            if (ggg.gtab_buf_select && poo.same_pho_query_state != SAME_PHO_QUERY_gtab_input)
              set_gbuf_c_sel(vv);
            else
              insert_gbuf_cursor1_cond(seltab[vv], ggg.kval, ggg.exa_match);
          }
          else {
            putstr_inp(seltab[vv]);
          }

          if (hime_pop_up_win && !gtab_has_input())
            hide_win_gtab();

          return 1;
        }
      }
#endif

//      dbg("iii %x sel1st_i:%d auto:%d\n", pselkey, ggg.sel1st_i, AUTO_SELECT_BY_PHRASE);
      if (seltab[ggg.sel1st_i][0] && !ggg.wild_mode &&
           (gtab_full_space_auto_first||ggg.spc_pressed||ggg.last_full) ) {
        if (AUTO_SELECT_BY_PHRASE && poo.same_pho_query_state != SAME_PHO_QUERY_gtab_input)
          insert_gbuf_cursor1_cond(seltab[ggg.sel1st_i], ggg.kval, ggg.exa_match);
        else
          putstr_inp(seltab[ggg.sel1st_i]);  /* select 1st */
      }
#if 0
      if (key > 0x7f) {
        return 0;
      }
#endif

      ggg.spc_pressed=0;

      // for cj & boshiamy to input digits
      if (!ggg.ci && !inkey) {
        if (current_CS->b_half_full_char)
          return full_char_proc(key);
        else {
          if (ggg.gbufN && poo.same_pho_query_state != SAME_PHO_QUERY_gtab_input) {
            insert_gbuf_cursor_char(key);
            return 1;
          }
          else
            return 0;
        }
      }

      if (ggg.wild_mode && inkey>=1 && ggg.ci< cur_inmd->MaxPress) {
        ggg.inch[ggg.ci++]=inkey;
        if (hime_pop_up_win)
          show_win_gtab();
        proc_wild_disp();
        return 1;
      }

      if (inkey>=1 && ggg.ci< cur_inmd->MaxPress) {
        ggg.inch[ggg.ci++]=inkey;
        hide_gtab_pre_sel();

        if (hime_pop_up_win)
          show_win_gtab();
        ggg.last_full=0;

        if (cur_inmd->use_quick && !pendkey) {
          if (ggg.ci==1) {
            int i;
            for(i=0;i < cur_inmd->M_DUP_SEL; i++) {
              utf8cpy(seltab[i], (char *)&cur_inmd->qkeys->quick1[inkey-1][i]);
            }

            ggg.defselN=cur_inmd->M_DUP_SEL;
            DispInArea();
            goto Disp_opt;
          } else
          if (ggg.ci==2 && !pselkey) {
            int i;
            for(i=0;i < cur_inmd->M_DUP_SEL; i++) {
              utf8cpy(seltab[i], (char *)&cur_inmd->qkeys->quick2[ggg.inch[0]-1][inkey-1][i]);
            }

            ggg.defselN=cur_inmd->M_DUP_SEL;
            DispInArea();
            goto Disp_opt;
          }
        }
      } else
      if (ggg.ci == cur_inmd->MaxPress && !pselkey) {
        bell();
        return 1;
      }


      if (inkey) {
        for(i=0; i < MAX_TAB_KEY_NUM64_6; i++)
          if (ggg.inch[i]>=cur_inmd->WILD_QUES) {
            DispInArea();
            if (ggg.ci==cur_inmd->MaxPress) {
              ggg.wild_mode=1;
              ggg.wild_page=0;
              wildcard();
            }

            return 1;
          }
      } else {
        if (!pselkey) {
          if (current_CS->b_half_full_char)
            return full_char_proc(key);
          else {
            if (key>=' ' && key<0x7f && AUTO_SELECT_BY_PHRASE && ggg.gbufN)
              insert_gbuf_cursor_char(key);
            else
              return 0;
          }
        }

        if (ggg.defselN) {
          goto YYYY;
        }
     }
  } /* switch */


  if (ggg.ci==0) {
    ClrSelArea();
    ClrIn();
    return 1;
  }

  ggg.invalid_spc = FALSE;
  char *pendkey = NULL;
  pendkey = strchr(cur_inmd->endkey, key);

  DispInArea();

  ggg.kval=0;

  for(i=0; i < Max_tab_key_num; i++) {
    ggg.kval|= (u_int64_t)ggg.inch[i] << (KeyBits * (Max_tab_key_num - 1 - i));
  }

#if 1
  if (ggg.last_idx)
    ggg.S1=ggg.last_idx;
  else
#endif
    ggg.S1=cur_inmd->idx1[ggg.inch[0]];

//  dbg("--------- ch:%d %d val %llx  ggg.S1:%d\n", ggg.inch[0], Max_tab_key_num, ggg.kval, ggg.S1);

  int oE1;
  oE1=cur_inmd->idx1[ggg.inch[0]+1];
  if (cur_inmd->keybits==6)
    vmaskci = cur_inmd->key64 ? vmask64[ggg.ci]:vmask[ggg.ci];
  else
    vmaskci = cur_inmd->key64 ? vmask64_7[ggg.ci]:vmask_7[ggg.ci];

  gtab_scan_pre_select(TRUE);

  while ((CONVT2(cur_inmd, ggg.S1) & vmaskci) != ggg.kval &&
          CONVT2(cur_inmd, ggg.S1) < ggg.kval &&  ggg.S1<oE1)
    ggg.S1++;

  ggg.pg_idx=ggg.last_idx=ggg.S1;


#if 0
  dbg("MaxPress:%d vmaskci:%llx kval:%llx ggg.ci:%d  !=%d  S1:%d  kval:%x\n", cur_inmd->MaxPress,
  vmaskci, ggg.kval, ggg.ci,
  ((CONVT2(cur_inmd, ggg.S1) & vmaskci)!=ggg.kval), ggg.S1);
#endif

  if ((CONVT2(cur_inmd, ggg.S1) & vmaskci)!=ggg.kval || (ggg.wild_mode && ggg.defselN) ||
                  ((/* ggg.ci==cur_inmd->MaxPress|| */ ggg.spc_pressed) && ggg.defselN &&
      (pselkey && ( pendkey || ggg.spc_pressed)) ) ) {
YYYY:

    if ((pselkey || ggg.wild_mode) && ggg.defselN) {
      int vv = pselkey - cur_inmd->selkey;

      if ((_gtab_space_auto_first & GTAB_space_auto_first_any) && !ggg.wild_mode
          && ggg.exa_match && (!cur_inmd->use_quick || ggg.ci!=2))
        vv++;

      if (vv<0)
        vv=9;

      if (seltab[vv][0]) {
        if (AUTO_SELECT_BY_PHRASE && poo.same_pho_query_state != SAME_PHO_QUERY_gtab_input)
          insert_gbuf_cursor1_cond(seltab[vv], ggg.kval, ggg.exa_match);
        else
          putstr_inp(seltab[vv]);
        return 1;
      }
    }

    if (pselkey && !ggg.defselN)
      return 0;

    if (gtab_invalid_key_in) {
      if (ggg.spc_pressed) {
        bell_err();
        ggg.invalid_spc = TRUE;
//        dbg("ggg.invalid_spc\n");
      } else {
        seltab[0][0]=0;
        ClrSelArea();
      }
    } else {
      if (gtab_dup_select_bell)
        bell();

      if (ggg.ci>0)
        ggg.inch[--ggg.ci]=0;
    }

    ggg.last_idx=0;
    DispInArea();
    return 1;
  }

//refill:

  j=ggg.S1;
  while(CONVT2(cur_inmd, j)==ggg.kval && j<oE1)
    j++;

  ggg.E1 = j;
  ggg.total_matchN = ggg.E1 - ggg.S1;
  ggg.pg_idx = ggg.S1;

  ggg.more_pg = 0;
  if (ggg.total_matchN > page_len()) {
    if ((_gtab_space_auto_first & GTAB_space_auto_first_any) || ggg.spc_pressed || pendkey ||
      (ggg.ci==cur_inmd->MaxPress && (_gtab_space_auto_first & GTAB_space_auto_first_full)))
      ggg.more_pg = 1;
  }

  if (ggg.ci < cur_inmd->MaxPress && !ggg.spc_pressed && !pendkey && !ggg.more_pg) {
    j = ggg.S1;
    ggg.exa_match=0;
    clr_seltab();
    int match_cnt=0;

    while (CONVT2(cur_inmd, j)==ggg.kval && ggg.exa_match <= page_len()) {
      seltab_phrase[ggg.exa_match] = load_seltab(j, ggg.exa_match);
      match_cnt++;
      ggg.exa_match++;
      j++;
    }

    ggg.defselN=ggg.exa_match;
//    dbg("--- ggg.exa_match %d\n", ggg.exa_match);

    if (ggg.defselN > page_len())
      ggg.defselN--;

    int shiftb=(KEY_N - 1 -ggg.ci) * KeyBits;

//    if (gtab_disp_partial_match_on)
    while((CONVT2(cur_inmd, j) & vmaskci)==ggg.kval && j<oE1) {
      int fff=cur_inmd->keycol[(CONVT2(cur_inmd, j)>>shiftb) & cur_inmd->kmask];
      u_char *tbl_ch = tblch(j);

      if (gtab_disp_partial_match_on() && (!seltab[fff][0] || seltab_phrase[fff] ||
           (bchcmp(seltab[fff], tbl_ch)>0 && fff > ggg.exa_match))) {
        seltab_phrase[fff] = load_seltab(j, fff);
        ggg.defselN++;
      }

      match_cnt++;
#if 0
      dbg("jj %d", fff); utf8_putchar(seltab[fff]); dbg("\n");
#endif
      j++;
    }

    if (gtab_unique_auto_send_on()) {
      char *first_str=NULL;
      for(i=0; i < page_len(); i++) {
        if (!seltab[i][0])
          continue;
        if (!first_str)
          first_str = seltab[i];
      }

      if (match_cnt==1 && first_str) {
        if (AUTO_SELECT_BY_PHRASE && poo.same_pho_query_state != SAME_PHO_QUERY_gtab_input)
          insert_gbuf_nokey(first_str);
        else
          putstr_inp(first_str);
        return 1;
      }
    }
  } else {
Exemplo n.º 27
0
int dcl_copy(PARAM_T *p,PARAM_T *q)
{
    COP_PARAM cop_param;
    char    vms[MAX_TOKEN];
    char    dos[MAX_TOKEN];
    int     i       = 0;
    int     s_recurse = 0;
    int     retcod  = DCL_OK;
    char    *szCmd = "COPY";

    NEXT_LINE();
    if (cmd[C].subr) return(DCL_OK);
    if (!dcl[D].cc[dcl[D].ccl]) return(DCL_OK);
    if (p == NULL || q == NULL) return(DCL_ERROR);

    SUBDIR = 0;
    _STATUS = 0;
    *vms = 0; *dos = 0;
    cop_param.all = 0;
    cop_param.confirm = 0;
    cop_param.log = 0;
    cop_param.replace = 1;
    cop_param.wildcard = 0;
    cop_param.file_nb = 0;
    cop_param.file_copied = 0;
    cop_param.vms[0] = 0;
    cop_param.before = -1;
    cop_param.since = 0;
    cop_param.ok = 1;
    cop_param.fnew = 0;
    cop_param.recurse = 0;

    retcod = cmd_parse_line(dcl_line,COPY_PARAM,COPY_QUAL,p,q);

    if (retcod == DCL_OK) {
        for (i = 0; q[i].tag; i++) {
            if (q[i].flag & PRESENT) 
                switch (q[i].tag) {
                case 1:                                 /* /ALL     */
                    cop_param.all = TRUE;
                    break;
                case 2:                                 /* /BEFORE  */
                    if (!*q[i].value) strcpy(q[i].value,"TODAY");
                    tm_str_to_long(q[i].value,&cop_param.before);
                    break;
                case 3:                                 /*  /CONFIRM */
                    cop_param.confirm = 1;
                    break;
                case 4:                                 /*  /NOCONFIRM */
                    cop_param.confirm = 0;
                    break;
                case 5:                                 /*  /LOG */
                    cop_param.log = 1;
                    break;
                case 6:                                 /*  /NOLOG */
                    cop_param.log = 0;
                    break;
                case 7:                                 /*  /NEW */
                    cop_param.fnew = 1;
                    break;
                case 8:                                 /*  /SINCE  */
                    if (!*q[i].value) strcpy(q[i].value,"TODAY");
                    tm_str_to_long(q[i].value,&cop_param.since);
                    break;
                case 9:                                 /*  /SUBDIR */
                    cop_param.recurse = 1;
                    break;
                case 10:                                /*  /NOSUBDIR */
                    cop_param.recurse = 0;
                    break;
                case 11:                                 /*  /REPLACE */
                    cop_param.replace = 1;
                    break;
                case 12:                                /*  /NOREPLACE */
                    cop_param.replace = 0;
                    break;
                default:
                    ;
                } /* end switch */
            }   /* end for */

        dcl_string(p[0].value,vms,MAX_TOKEN);
        dcl_string(p[1].value,cop_param.vms,MAX_TOKEN);
        cvfs_lst_to_dos(vms,dos,&s_recurse);
        if (s_recurse) cop_param.recurse = 1;
        if (dos[strlen(dos)-1] == ':')
            strcat(dos,"*.*");
        cop_param.wildcard = (char)wildcard(dos);
        (void)dcl_searchdirlst(szCmd,dos,cop_param.recurse,dclcopy_do_it,&cop_param);
        if (cop_param.file_nb == 0) {
            if (cop_param.wildcard)
                (void)dcl_printf(dcl[D].SYS_OUTPUT,"No file found.\n");
            else
                (void)dcl_printf(dcl[D].SYS_OUTPUT,"File not found.\n");
            _SEVERITY = 1;
            _STATUS = 2;
            retcod = DCL_ERROR;
        }
        else {
            if (cop_param.log && cop_param.file_copied > 1)
                (void)dcl_printf(dcl[D].SYS_OUTPUT,"%d files copied.\n",cop_param.file_copied);
        }
    }

    
    return(retcod);
}
Exemplo n.º 28
0
Project *
App::CreateNewProject(const BMessage &settings)
{
	Project *proj = NULL;
	
	BString projectName, targetName, projectPath, templateName, pldName;
	int32 projectType, scmType;
	bool createFolder, populateProject = true;
	
	settings.FindString("name",&projectName);
	settings.FindString("target",&targetName);
	settings.FindInt32("type",&projectType);
	settings.FindString("path",&projectPath);
	settings.FindInt32("scmtype", &scmType);
	settings.FindBool("createfolder",&createFolder);
	settings.FindString("template", &templateName);
	settings.FindString("pldfile", &pldName);

	if (templateName.CountChars() > 0)
	{
		// Templates are now a directory with a TEMPLATEINFO file. All files in the
		// directory are copies, allowing for much greater flexibility than before.
		
		BString projectFileName(projectName);
		projectFileName << ".pld";
		
		DPath templatePath(gAppPath.GetFolder());
		templatePath << "Templates" << templateName;
		
		// Copy the contents of the chosen template folder to the project path
		DPath sourcePath(templatePath);
		DPath destPath(gProjectPath);
		
		if (createFolder)
		{
			destPath << projectName;
			create_directory(destPath.GetFullPath(), 0700);
		}
		
		BString wildcard("'");
		wildcard << sourcePath.GetFullPath() << "'/*";
		ShellHelper shell("cp -a ");
		shell << wildcard;
		shell.AddQuotedArg(destPath.GetFullPath());
		shell.Run();
		
		// The copy command copies *everything*, so we have to delete the
		// TEMPLATEINFO file.
		DPath templateInfo(destPath);
		templateInfo << "TEMPLATEINFO";
		BEntry infoEntry(templateInfo.GetFullPath());
		infoEntry.Remove();
		infoEntry.Unset();
		
		DPath finalPath;
		
		// Load project and set info or create one, if needed.
		
		// If the settings contain the name of a .pld project file, we'll search
		// for that first. Assuming that it exists, we'll rename that file to the
		// project name specified. If it doesn't exist or the .pld name is empty,
		// we'll create a new project with the appropriate name.
		
		// The pldname field comes from the TEMPLATEINFO file, which can designate
		// the main project file in a template. This allows a template to have
		// multiple project files, such as for the Tracker Add-on development framework
		// which has both a project file for generating the actual addon and another
		// one which is the testing framework.
		bool createProjFile = true;
		if (pldName.CountChars() > 0)
		{
			// If a .pld project file was specified in TEMPLATEINFO, check to see if
			// the file exists and rename it. If it doesn't exist, we'll create a new
			// file, and if a .pld file already exists with the intended name, we won't
			// do anything except tell the user what's happened.
			DPath oldPldNamePath(destPath);
			oldPldNamePath << pldName;
			BEntry oldPldNameEntry(oldPldNamePath.GetFullPath());
			
			DPath newPldNamePath(destPath);
			newPldNamePath << projectFileName;
			
			BEntry newPldNameEntry(newPldNamePath.GetFullPath());
			if (newPldNameEntry.Exists())
			{
				// createProjFile is false here only if there is a .pld file with the
				// user's chosen project name. If that is the case, we keep both files and
				// let the user sort it out.
				BString errMsg = B_TRANSLATE(
					"Project file '%projectname%.pld' already exists. The "
					"original file for this template is '%pldname%'. You'll need "
					"to open the project folder and figure out which one you wish to keep.");
				errMsg.ReplaceFirst("%projectname%", projectName);
				errMsg.ReplaceFirst("%pldname%", pldName);
				ShowAlert(errMsg);
				populateProject = createProjFile = false;
				
				finalPath = newPldNamePath;
			}
			else
			if (oldPldNameEntry.Exists())
			{
				oldPldNameEntry.Rename(projectFileName.String());
				populateProject = createProjFile = false;
				
				finalPath = newPldNamePath;
			}
		}
		
		if (createProjFile)
		{
			proj = Project::CreateProject(projectName.String(), targetName.String(),
									projectType, projectPath.String(), createFolder);
			if (proj)
				finalPath = proj->GetPath();
		}
		else
		{
			proj = new Project();
			if (proj->Load(finalPath.GetFullPath()) != B_OK)
			{
				delete proj;
				return NULL;
			}
		}
	}
	else
	{
		// This case is for stuff like the Quick Import feature
		proj = Project::CreateProject(projectName.String(), targetName.String(),
									projectType, projectPath.String(), createFolder);
	}
	
	if (!proj)
		return NULL;
	
	scm_t detectedSCM = DetectSCM(projectPath);
	proj->SetSourceControl(detectedSCM == SCM_NONE ? (scm_t)scmType : detectedSCM);
	
	gCurrentProject = proj;
	gProjectList->Lock();
	gProjectList->AddItem(proj);
	gProjectList->Unlock();
	
	BRect r(0,0,200,300);
	/*
	r.OffsetTo(gProjectWindowPoint);
	gProjectWindowPoint.x += 25;
	gProjectWindowPoint.y += 25;
	if (gProjectWindowPoint.x < 0)
		gProjectWindowPoint.x = 0;
	if (gProjectWindowPoint.y < 0)
		gProjectWindowPoint.y - 0;
		*/
	ProjectWindow *projwin = new ProjectWindow(r,gCurrentProject);
	projwin->Show();
	
	BEntry entry(gCurrentProject->GetPath().GetFullPath());
	if (entry.InitCheck() == B_OK)
	{
		entry_ref newprojref;
		entry.GetRef(&newprojref);
		UpdateRecentItems(newprojref);
	}
	
	if (populateProject)
	{
		entry_ref addRef;
		int32 i = 0;
		while (settings.FindRef("libs",i++,&addRef) == B_OK)
		{
			if (BEntry(&addRef).Exists())
				proj->AddLibrary(DPath(addRef).GetFullPath());
		}
		
		i = 0;
		BMessage addMsg(M_IMPORT_REFS);
		while (settings.FindRef("refs",i++,&addRef) == B_OK)
			addMsg.AddRef("refs",&addRef);
		PostToProjectWindow(&addMsg,NULL);
	}
	
	return proj;
}
Exemplo n.º 29
0
    int
wildcard( char *wild, char *p, int sensitive )
{
    int		min, max;
    int		i, len;
    char	*comma, *end;

    for (;;) {
	switch ( *wild ) {
	case '*' :
	    wild++;

	    if ( *wild == '\0' ) {
		return( 1 );
	    }
	    for ( i = 0; p[ i ] != '\0'; i++ ) {
		if ( wildcard( wild, &p[ i ], sensitive )) {
		    return( 1 );
		}
	    }
	    return( 0 );

	case '<' :
	    wild++;

	    if ( ! isdigit( (int)*p )) {
		return( 0 );
	    }
	    i = atoi( p );
	    while ( isdigit( (int)*p )) p++;

	    if ( ! isdigit( (int)*wild )) {
		return( 0 );
	    }
	    min = atoi( wild );
	    while ( isdigit( (int)*wild )) wild++;

	    if ( *wild++ != '-' ) {
		return( 0 );
	    }

	    if ( ! isdigit( (int)*wild )) {
		return( 0 );
	    }
	    max = atoi( wild );
	    while ( isdigit( (int)*wild )) wild++;

	    if ( *wild++ != '>' ) {
		return( 0 );
	    }

	    if (( i < min ) || ( i > max )) {
		return( 0 );
	    }
	    break;

	case '?' :
	    wild++;
	    p++;
	    break;

	case '[' :
	    for ( wild++; *wild != ']'; wild++ ) {
		if ( sensitive ) {
		    if ( *wild != *p ) break;
		} else {
		    if ( tolower(*wild) != tolower(*p) ) break;
		}
	    }
	    if ( *wild == ']' ) {
		return( 0 );
	    }
	    for ( ; *wild; wild++ ) {
		if ( *wild == ']' ) {
		    break;
		}
	    }
	    if ( *wild == '\0' ) {
		return( 0 );
	    }

	    p++;
	    wild++;
	    break;

	case '{' :
	    comma = wild;

	    for ( end = wild + 1; *end != '}'; end++ ) {
		if ( *end == '{' || *end == '\0' ) {
		    /* malformed pattern */
		    return( 0 );
		}
	    }
	    end++;

	    do {
		for ( wild = ++comma; *comma != ',' && *comma != '}'; comma++ )
		    ;
		len = comma - wild;

		for ( i = 0; i < len; i++ ) {
		    if ( sensitive ) {
			if ( wild[ i ] != p[ i ] ) break;
		    } else {
			if ( tolower( wild[ i ] ) != tolower( p[ i ] )) break;
		    }
		}
		if ( i >= len && wildcard( end, &p[ i ], sensitive )) {
		    return( 1 );
		}
	    } while ( *comma != '}' );
	    return( 0 );

	case '\\' :
	    wild++;
	default :
	    if ( sensitive ) {
		if ( *wild != *p ) return( 0 );
	    } else {
		if ( tolower(*wild) != tolower(*p) ) return( 0 );
	    }
	    if ( *wild == '\0' ) {
		return( 1 );
	    }
	    wild++, p++;
	}
    }
}
Exemplo n.º 30
0
/*--------------------------------------------------------------------------*/
FilterResult opaque_op(SLPAttributes slp_attr, 
                       char *tag, 
                       int tag_len,
                       char *rhs, 
                       int rhs_len,
                       Operation op)
/* Perform an opaque operation.                                              */
/*--------------------------------------------------------------------------*/
{
    char *str_val; /* Converted value of rhs. */
    int str_len; /* Length of converted value. */

    var_t *var;

    assert(op != PRESENT);

    /***** Verify and convert rhs. *****/
    str_val = rhs;
    str_len = rhs_len;

    /***** Get tag value. *****/
    var = attr_val_find_str((struct xx_SLPAttributes *)slp_attr, tag, tag_len);
    if(var == NULL)
    {
        return FR_EVAL_FALSE;
    }
    /**** Check type. ****/
    if(var->type != SLP_OPAQUE)
    {
        return FR_EVAL_FALSE;
    }


    /***** Compare. *****/
    assert(op != PRESENT); 

    if(op == APPROX)
    {
        assert(0); /* TODO: Figure out how this works later. */
    }
    else if(op == EQUAL)
    {
        int result;
        value_t *value;

        for(value = var->list; value; value = value->next)
        {
            result = wildcard(str_val, str_len, value->data.va_str, value->unescaped_len);
            /* We only keep going if the test fails. Let caller handle other problems. */
            if(result != FR_EVAL_FALSE)
            {
                return result;
            }
        }
    }
    else
    {
        value_t *value;
        /* We know that the op must be comparative. */
        assert(op == LESS || op == GREATER);

        for(value = var->list; value; value = value->next)
        {
            int result;

            result = memcmp(value->data.va_str, str_val, MIN(str_len, value->unescaped_len));
            if(
              (result <= 0 && op == LESS) 
              || (result >= 0 && op == GREATER) 
              )
            {
                return FR_EVAL_TRUE;
            }
        }
    }

    return FR_EVAL_FALSE;
}