void StatusControl::Draw(DisplayDirector* director) { View* view = director->DrawingView(); view->PushState(); view->SetHighColor(controlColor); BRect rect = GetRect(); view->SetFont(font); int y = (int) (rect.top + font->Ascent()); int lineHeight = font->LineHeight(); // draw changed indicator if (director->IsDirty()) view->DrawString(string_slice(changedStr), rect.left, y); y += lineHeight; // draw mail indicator MessageFileSource* messageSource = dynamic_cast<MessageFileSource*>(director->GetDocSource()); if (messageSource) { if (messageSource->IsNewMessage()) { const char* msg = (messageSource->IsSent() ? sentStr : unsentStr); view->DrawString(string_slice(msg), rect.left, y); } } view->PopState(); }
string_slice NNTPResponse::NextField() { if (!SetupRead()) return string_slice(); // find the field const char* p = readByte; const char* stopper = readBuffer->end; // skip initial whitespace for (; p < stopper; p++) { char c = *p; if (c != ' ' && c != '\t' && c != '\r' && c != '\n') break; } // read the field, up until the next whitespace const char* fieldStart = p; for (; p < stopper; p++) { char c = *p; if (c == ' ' || c == '\t' || c == '\r' || c == '\n') break; } readByte = p; return string_slice(fieldStart, p); }
bool NNTPResponse::IsFinalBuffer(RespBuffer* buffer) { if (multiline) if (buffer->end - buffer->start >= 5) return (string_slice(buffer->end - 5, buffer->end) == "\r\n.\r\n"); else return (string_slice(buffer->end - 3, buffer->end) == ".\r\n"); else return (string_slice(buffer->end - 2, buffer->end) == "\r\n"); }
static gchar* playlists_menuitem_truncate_item_label_if_needs_be (PlaylistsMenuitem* self, const gchar* item_label) { gchar* result = NULL; const gchar* _tmp0_; gchar* _tmp1_; gchar* _result_; const gchar* _tmp2_; gint _tmp3_ = 0; g_return_val_if_fail (self != NULL, NULL); g_return_val_if_fail (item_label != NULL, NULL); _tmp0_ = item_label; _tmp1_ = g_strdup (_tmp0_); _result_ = _tmp1_; _tmp2_ = item_label; _tmp3_ = g_utf8_strlen (_tmp2_, (gssize) (-1)); if (_tmp3_ > 17) { const gchar* _tmp4_; gchar* _tmp5_ = NULL; const gchar* _tmp6_; gchar* _tmp7_; _tmp4_ = item_label; _tmp5_ = string_slice (_tmp4_, (glong) 0, (glong) 15); _g_free0 (_result_); _result_ = _tmp5_; _tmp6_ = _result_; _tmp7_ = g_strconcat (_tmp6_, "…", NULL); _g_free0 (_result_); _result_ = _tmp7_; } result = _result_; return result; }
void get_parent_directory(Value* filename, Value* result) { int end = string_length(filename); // Advance past trailing seperators. while (end > 0 && is_path_seperator(string_get(filename, end - 1))) end--; bool foundSep = false; while (end > 0) { while (end > 0 && is_path_seperator(string_get(filename, end - 1))) { foundSep = true; end--; } if (foundSep) break; end--; } if (end == 0) { if (is_absolute_path(filename)) set_string(result, "/"); else set_string(result, "."); } else string_slice(filename, 0, end, result); }
void get_just_filename_for_path(Value* path, Value* filenameOut) { int start = string_length(path) - 1; while (start > 0 && !is_path_seperator(string_get(path, start - 1))) start--; string_slice(path, start, -1, filenameOut); }
int shwild_match_pattern(shwild_handle_t hCompiledPattern, char const *string) { SHWILD_ASSERT(NULL != hCompiledPattern); SHWILD_ASSERT(NULL != string); shwild_slice_t string_slice(::strlen(string), string); return shwild_match_pattern_s(hCompiledPattern, &string_slice); }
BRect StatusControl::GetRect() { BRect viewBounds = director->ViewBounds(); BRect rect; rect.right = viewBounds.right - xPos; rect.left = rect.right - font->WidthOf(string_slice(changedStr)); rect.top = viewBounds.top + yPos; rect.bottom = rect.top + font->LineHeight(); return rect; }
void Filters::Load() { status_t err; // figure out where the file should be BPath path; err = find_directory(B_USER_SETTINGS_DIRECTORY, &path, true); if (err != B_NO_ERROR) return; path.Append(FileNames::filtersFileName); // open the file BFile* file = new BFile(path.Path(), B_READ_ONLY); if (file->InitCheck() != B_NO_ERROR) { delete file; return; } // load the text off_t fileSize; file->GetSize(&fileSize); char* text = new char[fileSize]; file->ReadAt(0, text, fileSize); delete file; // parse it TextReader reader(string_slice(text, text + fileSize)); FilterGroup* curGroup = NULL; while (!reader.AtEOF()) { // get the groupName string_slice groupName = reader.NextTabField(); if (groupName.length() > 0) { curGroup = GetFilterGroup(groupName); if (curGroup == NULL) { curGroup = new FilterGroup(groupName); AddFilterGroup(curGroup); } reader.NextLine(); } // if none, this is a filter line (if it's not blank) else { string_slice filterLine = reader.NextLine(); if (filterLine.length() > 0 && curGroup != NULL) { Filter* filter = new Filter(); TextReader lineReader(filterLine); filter->ReadFrom(&lineReader); curGroup->AddFilter(filter); } } } // clean up delete text; }
void string_split(caValue* s, char sep, caValue* listOut) { set_list(listOut, 0); int len = string_length(s); int wordStart = 0; for (int pos=0; pos <= len; pos++) { if (pos == len || string_get(s, pos) == sep) { string_slice(s, wordStart, pos, list_append(listOut)); wordStart = pos + 1; } } }
string_slice NNTPResponse::NextLine() { // NOTE: will return an extra blank line at the end if (!SetupRead()) return string_slice(); // find EOL const char* lineStart = readByte; const char* p = readByte; const char* stopper = readBuffer->end - 1; for (; p < stopper; p++) { if (*p == '\r' && p[1] == '\n') break; } readByte = p + 2; // skip the "\r\n" // un-escape lines beginning with '.' if (*lineStart == '.') lineStart++; return string_slice(lineStart, p); }
static void try_parse(Value* str, Value* msgList) { int msgStart = 0; for (int i=0; i < circa_string_length(str); i++) { if (circa_string(str)[i] == 0) { if (i > msgStart) { Value* msg = circa_append(msgList); circa_parse_string_len(circa_string(str), i - msgStart, msg); } msgStart = i + 1; } } if (msgStart > 0) string_slice(str, msgStart, -1); }
void AddCharsAction::IncorporateNext(Action* nextActionIn) { // incorporating AddCharsAction AddCharsAction* nextAction = dynamic_cast<AddCharsAction*>(nextActionIn); if (nextAction) { chars += nextAction->chars; } // incorporating BackCharAction BackCharsAction* backAction = dynamic_cast<BackCharsAction*>(nextActionIn); if (backAction) { // delete the last characters qstring newChars = string_slice(chars).substr(0, chars.length() - backAction->NumChars()); chars = newChars; } }
Filters::Filters() { // always has "All Groups" AddFilterGroup(new FilterGroup(string_slice(allGroupsName))); Load(); //*** test /*** FilterGroup* testGroup = new FilterGroup("rec.audio.pro"); Filter* testFilter = new Filter(); testFilter->SetString("Folta"); testGroup->AddFilter(testFilter); testGroup->AddFilter(new Filter(Hilite, Author, "Dorsey")); testGroup->AddFilter(new Filter(Hilite, Author, "Fletcher")); testGroup->AddFilter(new Filter(Hilite, Author, "Gerst")); testGroup->AddFilter(new Filter(Hilite, Author, "McQuilken")); testGroup->AddFilter(new Filter(Kill, Subject, "Spam Pan")); AddFilterGroup(testGroup); GetFilterGroup(string_slice(allGroupsName))->AddFilter(new Filter(Hilite, Author, "Folta")); ***/ }
string_slice NNTPResponse::NextTabField() { if (!SetupRead()) return string_slice(); // find the field const char* p = readByte; const char* stopper = readBuffer->end; const char* fieldStart = p; for (; p < stopper; p++) { char c = *p; if (c == '\t' || c == '\r' || c == '\n') break; } string_slice result(fieldStart, p); // skip the tab if (p < stopper && *p == '\t') p++; readByte = p; return result; }
gint skk_tool_main (gchar** args, int args_length1) { gint result = 0; const gchar* _tmp0_ = NULL; GOptionContext* _tmp1_; GOptionContext* option_context; GOptionContext* _tmp2_; gboolean _tmp7_; GeeArrayList* _tmp19_; GeeArrayList* dictionaries; const gchar* _tmp20_; const gchar* _tmp30_; const gchar* _tmp58_; GeeArrayList* _tmp86_; gint _tmp87_ = 0; gpointer* _tmp88_ = NULL; SkkDict** _tmp89_; gint _tmp89__length1; SkkContext* _tmp90_; SkkContext* _tmp91_; SkkContext* context; const gchar* _tmp92_; SkkContext* _tmp102_; SkkSkkTool* _tmp103_; SkkSkkTool* tool; SkkSkkTool* _tmp104_; gboolean _tmp105_ = FALSE; GError * _inner_error_ = NULL; setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); _tmp0_ = _ ("- emulate SKK input method on the command line"); _tmp1_ = g_option_context_new (_tmp0_); option_context = _tmp1_; _tmp2_ = option_context; g_option_context_add_main_entries (_tmp2_, SKK_TOOL_options, "libskk"); { GOptionContext* _tmp3_; _tmp3_ = option_context; g_option_context_parse (_tmp3_, &args_length1, &args, &_inner_error_); if (_inner_error_ != NULL) { if (_inner_error_->domain == G_OPTION_ERROR) { goto __catch0_g_option_error; } _g_option_context_free0 (option_context); g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return 0; } } goto __finally0; __catch0_g_option_error: { GError* e = NULL; FILE* _tmp4_; GError* _tmp5_; const gchar* _tmp6_; e = _inner_error_; _inner_error_ = NULL; _tmp4_ = stderr; _tmp5_ = e; _tmp6_ = _tmp5_->message; fprintf (_tmp4_, "%s\n", _tmp6_); result = 1; _g_error_free0 (e); _g_option_context_free0 (option_context); return result; } __finally0: if (_inner_error_ != NULL) { _g_option_context_free0 (option_context); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return 0; } skk_init (); _tmp7_ = skk_tool_list_typing_rules; if (_tmp7_) { gint _tmp8_ = 0; SkkRuleMetadata* _tmp9_ = NULL; SkkRuleMetadata* rules; gint rules_length1; gint _rules_size_; SkkRuleMetadata* _tmp10_; gint _tmp10__length1; _tmp9_ = skk_rule_list (&_tmp8_); rules = _tmp9_; rules_length1 = _tmp8_; _rules_size_ = rules_length1; _tmp10_ = rules; _tmp10__length1 = rules_length1; { SkkRuleMetadata* rule_collection = NULL; gint rule_collection_length1 = 0; gint _rule_collection_size_ = 0; gint rule_it = 0; rule_collection = _tmp10_; rule_collection_length1 = _tmp10__length1; for (rule_it = 0; rule_it < _tmp10__length1; rule_it = rule_it + 1) { SkkRuleMetadata _tmp11_ = {0}; SkkRuleMetadata rule = {0}; skk_rule_metadata_copy (&rule_collection[rule_it], &_tmp11_); rule = _tmp11_; { FILE* _tmp12_; SkkRuleMetadata _tmp13_; const gchar* _tmp14_; SkkRuleMetadata _tmp15_; const gchar* _tmp16_; SkkRuleMetadata _tmp17_; const gchar* _tmp18_; _tmp12_ = stdout; _tmp13_ = rule; _tmp14_ = _tmp13_.name; _tmp15_ = rule; _tmp16_ = _tmp15_.label; _tmp17_ = rule; _tmp18_ = _tmp17_.description; fprintf (_tmp12_, "%s - %s: %s\n", _tmp14_, _tmp16_, _tmp18_); skk_rule_metadata_destroy (&rule); } } } result = 0; rules = (_vala_SkkRuleMetadata_array_free (rules, rules_length1), NULL); _g_option_context_free0 (option_context); return result; } _tmp19_ = gee_array_list_new (SKK_TYPE_DICT, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL); dictionaries = _tmp19_; _tmp20_ = skk_tool_user_dict; if (_tmp20_ != NULL) { { const gchar* _tmp21_; SkkUserDict* _tmp22_; SkkUserDict* _tmp23_; GeeArrayList* _tmp24_; SkkUserDict* _tmp25_; _tmp21_ = skk_tool_user_dict; _tmp22_ = skk_user_dict_new (_tmp21_, "UTF-8", &_inner_error_); _tmp23_ = _tmp22_; if (_inner_error_ != NULL) { goto __catch1_g_error; } _tmp24_ = dictionaries; _tmp25_ = _tmp23_; gee_abstract_collection_add ((GeeAbstractCollection*) _tmp24_, (SkkDict*) _tmp25_); _g_object_unref0 (_tmp25_); } goto __finally1; __catch1_g_error: { GError* e = NULL; FILE* _tmp26_; const gchar* _tmp27_; GError* _tmp28_; const gchar* _tmp29_; e = _inner_error_; _inner_error_ = NULL; _tmp26_ = stderr; _tmp27_ = skk_tool_user_dict; _tmp28_ = e; _tmp29_ = _tmp28_->message; fprintf (_tmp26_, "can't open user dict %s: %s", _tmp27_, _tmp29_); result = 1; _g_error_free0 (e); _g_object_unref0 (dictionaries); _g_option_context_free0 (option_context); return result; } __finally1: if (_inner_error_ != NULL) { _g_object_unref0 (dictionaries); _g_option_context_free0 (option_context); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return 0; } } _tmp30_ = skk_tool_file_dict; if (_tmp30_ != NULL) { const gchar* _tmp31_; gboolean _tmp32_ = FALSE; _tmp31_ = skk_tool_file_dict; _tmp32_ = g_str_has_suffix (_tmp31_, ".cdb"); if (_tmp32_) { { const gchar* _tmp33_; SkkCdbDict* _tmp34_; SkkCdbDict* _tmp35_; GeeArrayList* _tmp36_; SkkCdbDict* _tmp37_; _tmp33_ = skk_tool_file_dict; _tmp34_ = skk_cdb_dict_new (_tmp33_, "EUC-JP", &_inner_error_); _tmp35_ = _tmp34_; if (_inner_error_ != NULL) { goto __catch2_g_error; } _tmp36_ = dictionaries; _tmp37_ = _tmp35_; gee_abstract_collection_add ((GeeAbstractCollection*) _tmp36_, (SkkDict*) _tmp37_); _g_object_unref0 (_tmp37_); } goto __finally2; __catch2_g_error: { GError* e = NULL; FILE* _tmp38_; const gchar* _tmp39_; GError* _tmp40_; const gchar* _tmp41_; e = _inner_error_; _inner_error_ = NULL; _tmp38_ = stderr; _tmp39_ = skk_tool_file_dict; _tmp40_ = e; _tmp41_ = _tmp40_->message; fprintf (_tmp38_, "can't open CDB dict %s: %s", _tmp39_, _tmp41_); result = 1; _g_error_free0 (e); _g_object_unref0 (dictionaries); _g_option_context_free0 (option_context); return result; } __finally2: if (_inner_error_ != NULL) { _g_object_unref0 (dictionaries); _g_option_context_free0 (option_context); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return 0; } } else { { const gchar* _tmp42_; SkkFileDict* _tmp43_; SkkFileDict* _tmp44_; GeeArrayList* _tmp45_; SkkFileDict* _tmp46_; _tmp42_ = skk_tool_file_dict; _tmp43_ = skk_file_dict_new (_tmp42_, "EUC-JP", &_inner_error_); _tmp44_ = _tmp43_; if (_inner_error_ != NULL) { goto __catch3_g_error; } _tmp45_ = dictionaries; _tmp46_ = _tmp44_; gee_abstract_collection_add ((GeeAbstractCollection*) _tmp45_, (SkkDict*) _tmp46_); _g_object_unref0 (_tmp46_); } goto __finally3; __catch3_g_error: { GError* e = NULL; FILE* _tmp47_; const gchar* _tmp48_; GError* _tmp49_; const gchar* _tmp50_; e = _inner_error_; _inner_error_ = NULL; _tmp47_ = stderr; _tmp48_ = skk_tool_file_dict; _tmp49_ = e; _tmp50_ = _tmp49_->message; fprintf (_tmp47_, "can't open file dict %s: %s", _tmp48_, _tmp50_); result = 1; _g_error_free0 (e); _g_object_unref0 (dictionaries); _g_option_context_free0 (option_context); return result; } __finally3: if (_inner_error_ != NULL) { _g_object_unref0 (dictionaries); _g_option_context_free0 (option_context); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return 0; } } } else { gchar* _tmp51_ = NULL; gchar* _tmp52_; SkkFileDict* _tmp53_; SkkFileDict* _tmp54_; SkkFileDict* _tmp55_; GeeArrayList* _tmp56_; SkkFileDict* _tmp57_; _tmp51_ = g_build_filename (DATADIR, "skk", "SKK-JISYO.L", NULL); _tmp52_ = _tmp51_; _tmp53_ = skk_file_dict_new (_tmp52_, "EUC-JP", &_inner_error_); _tmp54_ = _tmp53_; _g_free0 (_tmp52_); _tmp55_ = _tmp54_; if (_inner_error_ != NULL) { _g_object_unref0 (dictionaries); _g_option_context_free0 (option_context); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return 0; } _tmp56_ = dictionaries; _tmp57_ = _tmp55_; gee_abstract_collection_add ((GeeAbstractCollection*) _tmp56_, (SkkDict*) _tmp57_); _g_object_unref0 (_tmp57_); } _tmp58_ = skk_tool_skkserv; if (_tmp58_ != NULL) { const gchar* _tmp59_; gint _tmp60_ = 0; gint index; gchar* host = NULL; guint16 port = 0U; gint _tmp61_; _tmp59_ = skk_tool_skkserv; _tmp60_ = string_last_index_of (_tmp59_, ":", 0); index = _tmp60_; _tmp61_ = index; if (_tmp61_ < 0) { const gchar* _tmp62_; gchar* _tmp63_; _tmp62_ = skk_tool_skkserv; _tmp63_ = g_strdup (_tmp62_); _g_free0 (host); host = _tmp63_; port = (guint16) 1178; } else { const gchar* _tmp64_; gint _tmp65_; gchar* _tmp66_ = NULL; const gchar* _tmp67_; gint _tmp68_; const gchar* _tmp69_; gint _tmp70_; gint _tmp71_; gchar* _tmp72_ = NULL; gchar* _tmp73_; gint _tmp74_ = 0; _tmp64_ = skk_tool_skkserv; _tmp65_ = index; _tmp66_ = string_slice (_tmp64_, (glong) 0, (glong) _tmp65_); _g_free0 (host); host = _tmp66_; _tmp67_ = skk_tool_skkserv; _tmp68_ = index; _tmp69_ = skk_tool_skkserv; _tmp70_ = strlen (_tmp69_); _tmp71_ = _tmp70_; _tmp72_ = string_slice (_tmp67_, (glong) (_tmp68_ + 1), (glong) _tmp71_); _tmp73_ = _tmp72_; _tmp74_ = atoi (_tmp73_); port = (guint16) _tmp74_; _g_free0 (_tmp73_); } { const gchar* _tmp75_; guint16 _tmp76_; SkkSkkServ* _tmp77_; SkkSkkServ* _tmp78_; GeeArrayList* _tmp79_; SkkSkkServ* _tmp80_; _tmp75_ = host; _tmp76_ = port; _tmp77_ = skk_skk_serv_new (_tmp75_, _tmp76_, "EUC-JP", &_inner_error_); _tmp78_ = _tmp77_; if (_inner_error_ != NULL) { goto __catch4_g_error; } _tmp79_ = dictionaries; _tmp80_ = _tmp78_; gee_abstract_collection_add ((GeeAbstractCollection*) _tmp79_, (SkkDict*) _tmp80_); _g_object_unref0 (_tmp80_); } goto __finally4; __catch4_g_error: { GError* e = NULL; FILE* _tmp81_; const gchar* _tmp82_; guint16 _tmp83_; GError* _tmp84_; const gchar* _tmp85_; e = _inner_error_; _inner_error_ = NULL; _tmp81_ = stderr; _tmp82_ = host; _tmp83_ = port; _tmp84_ = e; _tmp85_ = _tmp84_->message; fprintf (_tmp81_, "can't connect to skkserv at %s:%d: %s", _tmp82_, (gint) _tmp83_, _tmp85_); result = 1; _g_error_free0 (e); _g_free0 (host); _g_object_unref0 (dictionaries); _g_option_context_free0 (option_context); return result; } __finally4: if (_inner_error_ != NULL) { _g_free0 (host); _g_object_unref0 (dictionaries); _g_option_context_free0 (option_context); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return 0; } _g_free0 (host); } _tmp86_ = dictionaries; _tmp88_ = gee_abstract_collection_to_array ((GeeAbstractCollection*) _tmp86_, &_tmp87_); _tmp89_ = _tmp88_; _tmp89__length1 = _tmp87_; _tmp90_ = skk_context_new (_tmp89_, _tmp87_); _tmp91_ = _tmp90_; _tmp89_ = (_vala_array_free (_tmp89_, _tmp89__length1, (GDestroyNotify) g_object_unref), NULL); context = _tmp91_; _tmp92_ = skk_tool_typing_rule; if (_tmp92_ != NULL) { { const gchar* _tmp93_; SkkRule* _tmp94_; SkkRule* _tmp95_; SkkContext* _tmp96_; SkkRule* _tmp97_; _tmp93_ = skk_tool_typing_rule; _tmp94_ = skk_rule_new (_tmp93_, &_inner_error_); _tmp95_ = _tmp94_; if (_inner_error_ != NULL) { if (_inner_error_->domain == SKK_RULE_PARSE_ERROR) { goto __catch5_skk_rule_parse_error; } _g_object_unref0 (context); _g_object_unref0 (dictionaries); _g_option_context_free0 (option_context); g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return 0; } _tmp96_ = context; _tmp97_ = _tmp95_; skk_context_set_typing_rule (_tmp96_, _tmp97_); _g_object_unref0 (_tmp97_); } goto __finally5; __catch5_skk_rule_parse_error: { GError* e = NULL; FILE* _tmp98_; const gchar* _tmp99_; GError* _tmp100_; const gchar* _tmp101_; e = _inner_error_; _inner_error_ = NULL; _tmp98_ = stderr; _tmp99_ = skk_tool_typing_rule; _tmp100_ = e; _tmp101_ = _tmp100_->message; fprintf (_tmp98_, "can't load rule \"%s\": %s\n", _tmp99_, _tmp101_); result = 1; _g_error_free0 (e); _g_object_unref0 (context); _g_object_unref0 (dictionaries); _g_option_context_free0 (option_context); return result; } __finally5: if (_inner_error_ != NULL) { _g_object_unref0 (context); _g_object_unref0 (dictionaries); _g_option_context_free0 (option_context); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return 0; } } _tmp102_ = context; _tmp103_ = skk_skk_tool_new (_tmp102_); tool = _tmp103_; _tmp104_ = tool; _tmp105_ = skk_tool_run ((SkkTool*) _tmp104_); if (!_tmp105_) { result = 1; _g_object_unref0 (tool); _g_object_unref0 (context); _g_object_unref0 (dictionaries); _g_option_context_free0 (option_context); return result; } result = 0; _g_object_unref0 (tool); _g_object_unref0 (context); _g_object_unref0 (dictionaries); _g_option_context_free0 (option_context); return result; }
static gchar* skk_skk_serv_read_response (SkkSkkServ* self, GError** error) { gchar* result = NULL; GString* _tmp0_; GString* builder; GString* _tmp21_; const gchar* _tmp22_; gint _tmp23_ = 0; gint index; gint _tmp24_; GString* _tmp26_; const gchar* _tmp27_; gint _tmp28_; gchar* _tmp29_ = NULL; GError * _inner_error_ = NULL; g_return_val_if_fail (self != NULL, NULL); _tmp0_ = g_string_new (""); builder = _tmp0_; while (TRUE) { GString* _tmp1_; const gchar* _tmp2_; gint _tmp3_ = 0; GSocketConnection* _tmp4_; GInputStream* _tmp5_; GInputStream* _tmp6_; gssize _tmp7_ = 0L; gssize len; gssize _tmp8_; _tmp1_ = builder; _tmp2_ = _tmp1_->str; _tmp3_ = string_index_of_char (_tmp2_, (gunichar) '\n', 0); if (!(_tmp3_ < 0)) { break; } _tmp4_ = self->priv->connection; _tmp5_ = g_io_stream_get_input_stream ((GIOStream*) _tmp4_); _tmp6_ = _tmp5_; _tmp7_ = g_input_stream_read (_tmp6_, self->priv->buffer, (gsize) 4096, NULL, &_inner_error_); len = _tmp7_; if (_inner_error_ != NULL) { if ((_inner_error_->domain == SKK_SKK_SERV_ERROR) || (_inner_error_->domain == G_IO_ERROR)) { g_propagate_error (error, _inner_error_); _g_string_free0 (builder); return NULL; } else { _g_string_free0 (builder); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return NULL; } } _tmp8_ = len; if (_tmp8_ < ((gssize) 0)) { GError* _tmp9_; _tmp9_ = g_error_new_literal (SKK_SKK_SERV_ERROR, SKK_SKK_SERV_ERROR_NOT_READABLE, "read error"); _inner_error_ = _tmp9_; if ((_inner_error_->domain == SKK_SKK_SERV_ERROR) || (_inner_error_->domain == G_IO_ERROR)) { g_propagate_error (error, _inner_error_); _g_string_free0 (builder); return NULL; } else { _g_string_free0 (builder); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return NULL; } } else { gssize _tmp10_; _tmp10_ = len; if (_tmp10_ == ((gssize) 0)) { break; } else { gssize _tmp11_; _tmp11_ = len; if (_tmp11_ > ((gssize) 0)) { guint8 _tmp12_; gssize _tmp14_; gchar* _tmp15_ = NULL; gchar* data; gint data_length1; gint _data_size_; gchar* _tmp16_; gint _tmp16__length1; gssize _tmp17_; gint _tmp18_; GString* _tmp19_; gchar* _tmp20_; gint _tmp20__length1; _tmp12_ = self->priv->buffer[0]; if (_tmp12_ != ((guint8) '1')) { GError* _tmp13_; _tmp13_ = g_error_new_literal (SKK_SKK_SERV_ERROR, SKK_SKK_SERV_ERROR_INVALID_RESPONSE, "invalid response code"); _inner_error_ = _tmp13_; if ((_inner_error_->domain == SKK_SKK_SERV_ERROR) || (_inner_error_->domain == G_IO_ERROR)) { g_propagate_error (error, _inner_error_); _g_string_free0 (builder); return NULL; } else { _g_string_free0 (builder); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return NULL; } } _tmp14_ = len; _tmp15_ = g_new0 (gchar, _tmp14_ + 1); data = _tmp15_; data_length1 = _tmp14_ + 1; _data_size_ = data_length1; _tmp16_ = data; _tmp16__length1 = data_length1; _tmp17_ = len; memcpy (_tmp16_, self->priv->buffer, (gsize) _tmp17_); _tmp18_ = data_length1; data_length1 = _tmp18_ - 1; _tmp19_ = builder; _tmp20_ = data; _tmp20__length1 = data_length1; g_string_append (_tmp19_, (const gchar*) _tmp20_); data = (g_free (data), NULL); } } } } _tmp21_ = builder; _tmp22_ = _tmp21_->str; _tmp23_ = string_index_of_char (_tmp22_, (gunichar) '\n', 0); index = _tmp23_; _tmp24_ = index; if (_tmp24_ < 0) { GError* _tmp25_; _tmp25_ = g_error_new_literal (SKK_SKK_SERV_ERROR, SKK_SKK_SERV_ERROR_INVALID_RESPONSE, "missing newline"); _inner_error_ = _tmp25_; if ((_inner_error_->domain == SKK_SKK_SERV_ERROR) || (_inner_error_->domain == G_IO_ERROR)) { g_propagate_error (error, _inner_error_); _g_string_free0 (builder); return NULL; } else { _g_string_free0 (builder); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return NULL; } } _tmp26_ = builder; _tmp27_ = _tmp26_->str; _tmp28_ = index; _tmp29_ = string_slice (_tmp27_, (glong) 0, (glong) _tmp28_); result = _tmp29_; _g_string_free0 (builder); return result; }
void do_admin_command(caValue* input, caValue* reply) { // Identify the command int first_space = string_find_char(input, 0, ' '); if (first_space == -1) first_space = string_length(input); Value command; string_slice(input, 0, first_space, &command); set_null(reply); if (equals_string(&command, "add_lib_path")) { //List args; //parse_tokens_as_argument_list(&tokens, &args); } else if (equals_string(&command, "file")) { List args; parse_string_as_argument_list(input, &args); do_file_command(&args, reply); } else if (equals_string(&command, "echo")) { List args; parse_string_as_argument_list(input, &args); do_echo(&args, reply); } else if (equals_string(&command, "write_block")) { int nextSpace = string_find_char(input, first_space+1, ' '); if (nextSpace == -1) { set_string(reply, "Syntax error, not enough arguments"); return; } Value blockName; string_slice(input, first_space+1, nextSpace, &blockName); Value contents; string_slice(input, nextSpace+1, -1, &contents); do_write_block(&blockName, &contents, reply); } else if (equals_string(&command, "update_file")) { int nextSpace = string_find_char(input, first_space+1, ' '); if (nextSpace == -1) { set_string(reply, "Syntax error, not enough arguments"); return; } Value filename; string_slice(input, first_space+1, nextSpace, &filename); Value contents; string_slice(input, nextSpace+1, -1, &contents); do_update_file(&filename, &contents, reply); } else if (equals_string(&command, "source_repro")) { List args; parse_string_as_argument_list(input, &args); Block block; load_script(&block, as_cstring(args[1])); std::cout << get_block_source_text(&block); } else if (equals_string(&command, "dump_stats")) { perf_stats_dump(); std::cout << ":done" << std::endl; } else { set_string(reply, "Unrecognized command: "); string_append(reply, &command); } }
KkcOkuriganaTemplate* kkc_okurigana_template_construct (GType object_type, const gchar* source) { KkcOkuriganaTemplate * self = NULL; gint count = 0; const gchar* _tmp0_ = NULL; gint _tmp1_ = 0; gint _tmp2_ = 0; g_return_val_if_fail (source != NULL, NULL); self = (KkcOkuriganaTemplate*) g_object_new (object_type, NULL); _tmp0_ = source; _tmp1_ = g_utf8_strlen (_tmp0_, (gssize) (-1)); count = _tmp1_; _tmp2_ = count; if (_tmp2_ > 1) { gint last_char_index = 0; const gchar* _tmp3_ = NULL; gint _tmp4_ = 0; gint _tmp5_ = 0; const gchar* _tmp6_ = NULL; gint _tmp7_ = 0; const gchar* _tmp8_ = NULL; gint _tmp9_ = 0; gint _tmp10_ = 0; gchar* _tmp11_ = NULL; gchar* prefix = NULL; const gchar* _tmp12_ = NULL; gchar* _tmp13_ = NULL; const gchar* _tmp14_ = NULL; gint _tmp15_ = 0; gchar* _tmp16_ = NULL; gchar* _tmp17_ = NULL; const gchar* _tmp18_ = NULL; gchar* _tmp19_ = NULL; gchar* _tmp20_ = NULL; _tmp3_ = source; _tmp4_ = count; _tmp5_ = string_index_of_nth_char (_tmp3_, (glong) (_tmp4_ - 1)); last_char_index = _tmp5_; _tmp6_ = source; _tmp7_ = last_char_index; _tmp8_ = source; _tmp9_ = strlen (_tmp8_); _tmp10_ = _tmp9_; _tmp11_ = string_slice (_tmp6_, (glong) _tmp7_, (glong) _tmp10_); _g_free0 (self->priv->okurigana); self->priv->okurigana = _tmp11_; _tmp12_ = self->priv->okurigana; _tmp13_ = kkc_rom_kana_utils_get_okurigana_prefix (_tmp12_); prefix = _tmp13_; _tmp14_ = source; _tmp15_ = last_char_index; _tmp16_ = string_slice (_tmp14_, (glong) 0, (glong) _tmp15_); _tmp17_ = _tmp16_; _tmp18_ = prefix; _tmp19_ = g_strconcat (_tmp17_, _tmp18_, NULL); _tmp20_ = _tmp19_; kkc_template_set_source ((KkcTemplate*) self, _tmp20_); _g_free0 (_tmp20_); _g_free0 (_tmp17_); kkc_template_set_okuri ((KkcTemplate*) self, TRUE); _g_free0 (prefix); } else { const gchar* _tmp21_ = NULL; _tmp21_ = source; kkc_template_set_source ((KkcTemplate*) self, _tmp21_); kkc_template_set_okuri ((KkcTemplate*) self, FALSE); } return self; }
static void skk_map_file_load (SkkMapFile* self, const gchar* rule, const gchar* type, const gchar* name, GeeSet* included, GError** error) { const gchar* _tmp0_; SkkRuleMetadata* _tmp1_ = NULL; SkkRuleMetadata* metadata; SkkRuleMetadata* _tmp2_; SkkRuleMetadata* _tmp5_; const gchar* _tmp6_; const gchar* _tmp7_; const gchar* _tmp8_; gchar* _tmp9_; gchar* _tmp10_; gchar* _tmp11_ = NULL; gchar* _tmp12_; gchar* filename; const gchar* _tmp13_; gboolean _tmp14_ = FALSE; JsonParser* _tmp17_; JsonParser* parser; JsonParser* _tmp30_; JsonNode* _tmp31_ = NULL; JsonNode* _tmp32_; JsonNode* root; JsonNode* _tmp33_; JsonNodeType _tmp34_ = 0; JsonNode* _tmp36_; JsonObject* _tmp37_ = NULL; JsonObject* _tmp38_; JsonObject* object; JsonNode* member = NULL; JsonObject* _tmp39_; gboolean _tmp40_ = FALSE; JsonObject* _tmp83_; gboolean _tmp84_ = FALSE; GError * _inner_error_ = NULL; g_return_if_fail (self != NULL); g_return_if_fail (rule != NULL); g_return_if_fail (type != NULL); g_return_if_fail (name != NULL); g_return_if_fail (included != NULL); _tmp0_ = rule; _tmp1_ = skk_rule_find_rule (_tmp0_); metadata = _tmp1_; _tmp2_ = metadata; if (_tmp2_ == NULL) { const gchar* _tmp3_; GError* _tmp4_; _tmp3_ = rule; _tmp4_ = g_error_new (SKK_RULE_PARSE_ERROR, SKK_RULE_PARSE_ERROR_FAILED, "can't find rule %s", _tmp3_); _inner_error_ = _tmp4_; if (_inner_error_->domain == SKK_RULE_PARSE_ERROR) { g_propagate_error (error, _inner_error_); _skk_rule_metadata_free0 (metadata); return; } else { _skk_rule_metadata_free0 (metadata); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } } _tmp5_ = metadata; _tmp6_ = (*_tmp5_).base_dir; _tmp7_ = type; _tmp8_ = name; _tmp9_ = g_strconcat (_tmp8_, ".json", NULL); _tmp10_ = _tmp9_; _tmp11_ = g_build_filename (_tmp6_, _tmp7_, _tmp10_, NULL); _tmp12_ = _tmp11_; _g_free0 (_tmp10_); filename = _tmp12_; _tmp13_ = filename; _tmp14_ = g_file_test (_tmp13_, G_FILE_TEST_EXISTS); if (!_tmp14_) { const gchar* _tmp15_; GError* _tmp16_; _tmp15_ = filename; _tmp16_ = g_error_new (SKK_RULE_PARSE_ERROR, SKK_RULE_PARSE_ERROR_FAILED, "no such file %s", _tmp15_); _inner_error_ = _tmp16_; if (_inner_error_->domain == SKK_RULE_PARSE_ERROR) { g_propagate_error (error, _inner_error_); _g_free0 (filename); _skk_rule_metadata_free0 (metadata); return; } else { _g_free0 (filename); _skk_rule_metadata_free0 (metadata); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } } _tmp17_ = json_parser_new (); parser = _tmp17_; { JsonParser* _tmp18_; const gchar* _tmp19_; gboolean _tmp20_ = FALSE; gboolean _tmp21_; _tmp18_ = parser; _tmp19_ = filename; _tmp20_ = json_parser_load_from_file (_tmp18_, _tmp19_, &_inner_error_); _tmp21_ = _tmp20_; if (_inner_error_ != NULL) { goto __catch28_g_error; } if (!_tmp21_) { GError* _tmp22_; _tmp22_ = g_error_new_literal (SKK_RULE_PARSE_ERROR, SKK_RULE_PARSE_ERROR_FAILED, ""); _inner_error_ = _tmp22_; goto __catch28_g_error; } } goto __finally28; __catch28_g_error: { GError* e = NULL; const gchar* _tmp23_; GError* _tmp24_; const gchar* _tmp25_; gchar* _tmp26_ = NULL; gchar* _tmp27_; GError* _tmp28_; GError* _tmp29_; e = _inner_error_; _inner_error_ = NULL; _tmp23_ = filename; _tmp24_ = e; _tmp25_ = _tmp24_->message; _tmp26_ = g_strdup_printf ("can't load %s: %s", _tmp23_, _tmp25_); _tmp27_ = _tmp26_; _tmp28_ = g_error_new_literal (SKK_RULE_PARSE_ERROR, SKK_RULE_PARSE_ERROR_FAILED, _tmp27_); _tmp29_ = _tmp28_; _g_free0 (_tmp27_); _inner_error_ = _tmp29_; _g_error_free0 (e); goto __finally28; } __finally28: if (_inner_error_ != NULL) { if (_inner_error_->domain == SKK_RULE_PARSE_ERROR) { g_propagate_error (error, _inner_error_); _g_object_unref0 (parser); _g_free0 (filename); _skk_rule_metadata_free0 (metadata); return; } else { _g_object_unref0 (parser); _g_free0 (filename); _skk_rule_metadata_free0 (metadata); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } } _tmp30_ = parser; _tmp31_ = json_parser_get_root (_tmp30_); _tmp32_ = __vala_JsonNode_copy0 (_tmp31_); root = _tmp32_; _tmp33_ = root; _tmp34_ = json_node_get_node_type (_tmp33_); if (_tmp34_ != JSON_NODE_OBJECT) { GError* _tmp35_; _tmp35_ = g_error_new_literal (SKK_RULE_PARSE_ERROR, SKK_RULE_PARSE_ERROR_FAILED, "root element must be an object"); _inner_error_ = _tmp35_; if (_inner_error_->domain == SKK_RULE_PARSE_ERROR) { g_propagate_error (error, _inner_error_); __vala_JsonNode_free0 (root); _g_object_unref0 (parser); _g_free0 (filename); _skk_rule_metadata_free0 (metadata); return; } else { __vala_JsonNode_free0 (root); _g_object_unref0 (parser); _g_free0 (filename); _skk_rule_metadata_free0 (metadata); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } } _tmp36_ = root; _tmp37_ = json_node_get_object (_tmp36_); _tmp38_ = __vala_JsonObject_copy0 (_tmp37_); object = _tmp38_; _tmp39_ = object; _tmp40_ = json_object_has_member (_tmp39_, "include"); if (_tmp40_) { JsonObject* _tmp41_; JsonNode* _tmp42_ = NULL; JsonNode* _tmp43_; JsonNode* _tmp44_; JsonNodeType _tmp45_ = 0; JsonNode* _tmp47_; JsonArray* _tmp48_ = NULL; JsonArray* _tmp49_; JsonArray* include; JsonArray* _tmp50_; GList* _tmp51_ = NULL; GList* elements; GList* _tmp52_; _tmp41_ = object; _tmp42_ = json_object_get_member (_tmp41_, "include"); _tmp43_ = __vala_JsonNode_copy0 (_tmp42_); __vala_JsonNode_free0 (member); member = _tmp43_; _tmp44_ = member; _tmp45_ = json_node_get_node_type (_tmp44_); if (_tmp45_ != JSON_NODE_ARRAY) { GError* _tmp46_; _tmp46_ = g_error_new_literal (SKK_RULE_PARSE_ERROR, SKK_RULE_PARSE_ERROR_FAILED, "\"include\" element must be an array"); _inner_error_ = _tmp46_; if (_inner_error_->domain == SKK_RULE_PARSE_ERROR) { g_propagate_error (error, _inner_error_); __vala_JsonNode_free0 (member); __vala_JsonObject_free0 (object); __vala_JsonNode_free0 (root); _g_object_unref0 (parser); _g_free0 (filename); _skk_rule_metadata_free0 (metadata); return; } else { __vala_JsonNode_free0 (member); __vala_JsonObject_free0 (object); __vala_JsonNode_free0 (root); _g_object_unref0 (parser); _g_free0 (filename); _skk_rule_metadata_free0 (metadata); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } } _tmp47_ = member; _tmp48_ = json_node_get_array (_tmp47_); _tmp49_ = __vala_JsonArray_copy0 (_tmp48_); include = _tmp49_; _tmp50_ = include; _tmp51_ = json_array_get_elements (_tmp50_); elements = _tmp51_; _tmp52_ = elements; { GList* element_collection = NULL; GList* element_it = NULL; element_collection = _tmp52_; for (element_it = element_collection; element_it != NULL; element_it = element_it->next) { JsonNode* element = NULL; element = (JsonNode*) element_it->data; { JsonNode* _tmp53_; const gchar* _tmp54_ = NULL; gchar* _tmp55_; gchar* parent; GeeSet* _tmp56_; const gchar* _tmp57_; gboolean _tmp58_ = FALSE; const gchar* _tmp61_; gint _tmp62_ = 0; gint index; gint _tmp63_; GeeSet* _tmp81_; const gchar* _tmp82_; _tmp53_ = element; _tmp54_ = json_node_get_string (_tmp53_); _tmp55_ = g_strdup (_tmp54_); parent = _tmp55_; _tmp56_ = included; _tmp57_ = parent; _tmp58_ = gee_collection_contains ((GeeCollection*) _tmp56_, _tmp57_); if (_tmp58_) { const gchar* _tmp59_; GError* _tmp60_; _tmp59_ = parent; _tmp60_ = g_error_new (SKK_RULE_PARSE_ERROR, SKK_RULE_PARSE_ERROR_FAILED, "found circular include of %s", _tmp59_); _inner_error_ = _tmp60_; if (_inner_error_->domain == SKK_RULE_PARSE_ERROR) { g_propagate_error (error, _inner_error_); _g_free0 (parent); _g_list_free0 (elements); __vala_JsonArray_free0 (include); __vala_JsonNode_free0 (member); __vala_JsonObject_free0 (object); __vala_JsonNode_free0 (root); _g_object_unref0 (parser); _g_free0 (filename); _skk_rule_metadata_free0 (metadata); return; } else { _g_free0 (parent); _g_list_free0 (elements); __vala_JsonArray_free0 (include); __vala_JsonNode_free0 (member); __vala_JsonObject_free0 (object); __vala_JsonNode_free0 (root); _g_object_unref0 (parser); _g_free0 (filename); _skk_rule_metadata_free0 (metadata); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } } _tmp61_ = parent; _tmp62_ = string_index_of (_tmp61_, "/", 0); index = _tmp62_; _tmp63_ = index; if (_tmp63_ < 0) { const gchar* _tmp64_; const gchar* _tmp65_; const gchar* _tmp66_; GeeSet* _tmp67_; _tmp64_ = rule; _tmp65_ = type; _tmp66_ = parent; _tmp67_ = included; skk_map_file_load (self, _tmp64_, _tmp65_, _tmp66_, _tmp67_, &_inner_error_); if (_inner_error_ != NULL) { if (_inner_error_->domain == SKK_RULE_PARSE_ERROR) { g_propagate_error (error, _inner_error_); _g_free0 (parent); _g_list_free0 (elements); __vala_JsonArray_free0 (include); __vala_JsonNode_free0 (member); __vala_JsonObject_free0 (object); __vala_JsonNode_free0 (root); _g_object_unref0 (parser); _g_free0 (filename); _skk_rule_metadata_free0 (metadata); return; } else { _g_free0 (parent); _g_list_free0 (elements); __vala_JsonArray_free0 (include); __vala_JsonNode_free0 (member); __vala_JsonObject_free0 (object); __vala_JsonNode_free0 (root); _g_object_unref0 (parser); _g_free0 (filename); _skk_rule_metadata_free0 (metadata); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } } } else { const gchar* _tmp68_; gint _tmp69_; gchar* _tmp70_ = NULL; gchar* _tmp71_; const gchar* _tmp72_; const gchar* _tmp73_; gint _tmp74_; const gchar* _tmp75_; gint _tmp76_; gint _tmp77_; gchar* _tmp78_ = NULL; gchar* _tmp79_; GeeSet* _tmp80_; _tmp68_ = parent; _tmp69_ = index; _tmp70_ = string_slice (_tmp68_, (glong) 0, (glong) _tmp69_); _tmp71_ = _tmp70_; _tmp72_ = type; _tmp73_ = parent; _tmp74_ = index; _tmp75_ = parent; _tmp76_ = strlen (_tmp75_); _tmp77_ = _tmp76_; _tmp78_ = string_slice (_tmp73_, (glong) (_tmp74_ + 1), (glong) _tmp77_); _tmp79_ = _tmp78_; _tmp80_ = included; skk_map_file_load (self, _tmp71_, _tmp72_, _tmp79_, _tmp80_, &_inner_error_); _g_free0 (_tmp79_); _g_free0 (_tmp71_); if (_inner_error_ != NULL) { if (_inner_error_->domain == SKK_RULE_PARSE_ERROR) { g_propagate_error (error, _inner_error_); _g_free0 (parent); _g_list_free0 (elements); __vala_JsonArray_free0 (include); __vala_JsonNode_free0 (member); __vala_JsonObject_free0 (object); __vala_JsonNode_free0 (root); _g_object_unref0 (parser); _g_free0 (filename); _skk_rule_metadata_free0 (metadata); return; } else { _g_free0 (parent); _g_list_free0 (elements); __vala_JsonArray_free0 (include); __vala_JsonNode_free0 (member); __vala_JsonObject_free0 (object); __vala_JsonNode_free0 (root); _g_object_unref0 (parser); _g_free0 (filename); _skk_rule_metadata_free0 (metadata); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } } } _tmp81_ = included; _tmp82_ = parent; gee_collection_add ((GeeCollection*) _tmp81_, _tmp82_); _g_free0 (parent); } } } _g_list_free0 (elements); __vala_JsonArray_free0 (include); } _tmp83_ = object; _tmp84_ = json_object_has_member (_tmp83_, "define"); if (_tmp84_) { JsonObject* _tmp85_; JsonNode* _tmp86_ = NULL; JsonNode* _tmp87_; JsonNode* _tmp88_; JsonNodeType _tmp89_ = 0; JsonNode* _tmp91_; JsonObject* _tmp92_ = NULL; JsonObject* _tmp93_; JsonObject* define; JsonObject* _tmp94_; GList* _tmp95_ = NULL; GList* keys; GList* _tmp96_; _tmp85_ = object; _tmp86_ = json_object_get_member (_tmp85_, "define"); _tmp87_ = __vala_JsonNode_copy0 (_tmp86_); __vala_JsonNode_free0 (member); member = _tmp87_; _tmp88_ = member; _tmp89_ = json_node_get_node_type (_tmp88_); if (_tmp89_ != JSON_NODE_OBJECT) { GError* _tmp90_; _tmp90_ = g_error_new_literal (SKK_RULE_PARSE_ERROR, SKK_RULE_PARSE_ERROR_FAILED, "\"define\" element must be an object"); _inner_error_ = _tmp90_; if (_inner_error_->domain == SKK_RULE_PARSE_ERROR) { g_propagate_error (error, _inner_error_); __vala_JsonNode_free0 (member); __vala_JsonObject_free0 (object); __vala_JsonNode_free0 (root); _g_object_unref0 (parser); _g_free0 (filename); _skk_rule_metadata_free0 (metadata); return; } else { __vala_JsonNode_free0 (member); __vala_JsonObject_free0 (object); __vala_JsonNode_free0 (root); _g_object_unref0 (parser); _g_free0 (filename); _skk_rule_metadata_free0 (metadata); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } } _tmp91_ = member; _tmp92_ = json_node_get_object (_tmp91_); _tmp93_ = __vala_JsonObject_copy0 (_tmp92_); define = _tmp93_; _tmp94_ = define; _tmp95_ = json_object_get_members (_tmp94_); keys = _tmp95_; _tmp96_ = keys; { GList* key_collection = NULL; GList* key_it = NULL; key_collection = _tmp96_; for (key_it = key_collection; key_it != NULL; key_it = key_it->next) { const gchar* key = NULL; key = (const gchar*) key_it->data; { GeeMap* _tmp97_; const gchar* _tmp98_; gboolean _tmp99_ = FALSE; JsonObject* _tmp104_; const gchar* _tmp105_; JsonNode* _tmp106_ = NULL; JsonNode* _tmp107_; JsonNode* _tmp108_; JsonNodeType _tmp109_ = 0; GeeMap* _tmp111_; const gchar* _tmp112_; gpointer _tmp113_ = NULL; GeeMap* _tmp114_; JsonNode* _tmp115_; JsonObject* _tmp116_ = NULL; _tmp97_ = self->priv->maps; _tmp98_ = key; _tmp99_ = gee_map_has_key (_tmp97_, _tmp98_); if (!_tmp99_) { GeeHashMap* _tmp100_; GeeHashMap* map; GeeMap* _tmp101_; const gchar* _tmp102_; GeeHashMap* _tmp103_; _tmp100_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, json_node_get_type (), (GBoxedCopyFunc) _vala_JsonNode_copy, _vala_JsonNode_free, NULL, NULL, NULL); map = _tmp100_; _tmp101_ = self->priv->maps; _tmp102_ = key; _tmp103_ = map; gee_map_set (_tmp101_, _tmp102_, (GeeMap*) _tmp103_); _g_object_unref0 (map); } _tmp104_ = define; _tmp105_ = key; _tmp106_ = json_object_get_member (_tmp104_, _tmp105_); _tmp107_ = __vala_JsonNode_copy0 (_tmp106_); __vala_JsonNode_free0 (member); member = _tmp107_; _tmp108_ = member; _tmp109_ = json_node_get_node_type (_tmp108_); if (_tmp109_ != JSON_NODE_OBJECT) { GError* _tmp110_; _tmp110_ = g_error_new_literal (SKK_RULE_PARSE_ERROR, SKK_RULE_PARSE_ERROR_FAILED, "map element must be an object"); _inner_error_ = _tmp110_; if (_inner_error_->domain == SKK_RULE_PARSE_ERROR) { g_propagate_error (error, _inner_error_); _g_list_free0 (keys); __vala_JsonObject_free0 (define); __vala_JsonNode_free0 (member); __vala_JsonObject_free0 (object); __vala_JsonNode_free0 (root); _g_object_unref0 (parser); _g_free0 (filename); _skk_rule_metadata_free0 (metadata); return; } else { _g_list_free0 (keys); __vala_JsonObject_free0 (define); __vala_JsonNode_free0 (member); __vala_JsonObject_free0 (object); __vala_JsonNode_free0 (root); _g_object_unref0 (parser); _g_free0 (filename); _skk_rule_metadata_free0 (metadata); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } } _tmp111_ = self->priv->maps; _tmp112_ = key; _tmp113_ = gee_map_get (_tmp111_, _tmp112_); _tmp114_ = (GeeMap*) _tmp113_; _tmp115_ = member; _tmp116_ = json_node_get_object (_tmp115_); skk_map_file_load_map (self, _tmp114_, _tmp116_); _g_object_unref0 (_tmp114_); } } } _g_list_free0 (keys); __vala_JsonObject_free0 (define); } __vala_JsonNode_free0 (member); __vala_JsonObject_free0 (object); __vala_JsonNode_free0 (root); _g_object_unref0 (parser); _g_free0 (filename); _skk_rule_metadata_free0 (metadata); }
int main(void) { string_t temp; string_t string1 = string_new("hello world"); string_t string2 = string_new("another"); string_t string3 = string_new("a third"); printf("Testing new()...\n"); assert(strcmp("hello world", string1.bytes) == 0); printf("Testing at()...\n"); assert(*string_at(string1, 4) == 'o'); assert(*string_at(string1, -1) == 'd'); assert(string_at(string1, 100) == NULL); assert(string_at(string1, -100) == NULL); printf("Testing cmp()...\n"); assert(string_cmp(string1, string1) == 0); assert(string_cmp(string1, string2) > 0); assert(string_cmp(string2, string1) < 0); printf("Testing eq()...\n"); assert(string_eq(string1, string1)); assert(! string_eq(string1, string2)); printf("Testing cat()...\n"); temp = string_cat(string1, string2); assert(temp.length == string1.length + string2.length); assert(strncmp(string1.bytes, temp.bytes, string1.length) == 0); assert(strcmp(string2.bytes, temp.bytes + string1.length) == 0); string_free(temp); printf("Testing slice()...\n"); temp = string_slice(string1, 1, 6); assert(strcmp(temp.bytes, "ello")); string_free(temp); temp = string_slice(string1, 1, -1); assert(strcmp(temp.bytes, "ello worl") == 0); string_free(temp); temp = string_slice(string1, -5, -2); assert(strcmp(temp.bytes, "wor") == 0); string_free(temp); temp = string_slice(string1, -100, 100); assert(strcmp(temp.bytes, "hello world") == 0); string_free(temp); printf("Testing split()...\n"); string_split_t split = string_split_init(string1, 'o'); temp = string_split_next(&split); assert(strcmp(temp.bytes, "hell") == 0); string_free(temp); temp = string_split_next(&split); assert(strcmp(temp.bytes, " w") == 0); string_free(temp); temp = string_split_next(&split); assert(strcmp(temp.bytes, "rld") == 0); string_free(temp); temp = string_split_next(&split); assert(! temp.bytes); string_free(temp); printf("Testing join()...\n"); string_t parts[] = {string1, string2, string3}; temp = string_join(parts, 3, ' '); assert(strcmp(temp.bytes, "hello world another a third") == 0); string_free(temp); // string_t[] parts = {s1, s2, s3}; // int joined = join(parts, sizeof(parts) / sizeof(*parts)); string_free(string1); string_free(string2); string_free(string3); printf("All tests passed.\n"); return 0; }
FilterGroup* Filters::GetGlobalFilters() { return GetFilterGroup(string_slice(allGroupsName)); }
ussval_t* string_substr(ussval_t* n, ussval_t* str) { int32_t string_start = n->num; size_t string_length = strlen(str->str); return string_slice(n, ussval_new_num(string_length - string_start), str);; }