void aux (char* x,char* y,int esperado){ int exito; char* salio[]={"FALLO","OK"}; int resultado= compare_tags(x,y); if(resultado==esperado){ exito=1; }else{ exito=0; } printf("%s vs %s -> %d : %s\n",x,y,resultado,salio[exito]); }
bool es_tag_sin_abrir(char* cerro, int count, char* pila[]) { /*int i; for (i = 0; i < count; i+=2) { bool tags_son_iguales = compare_tags(pila[i], cerro); if(tags_son_iguales){ return false; } }*/ while (count != 0) { bool tags_son_iguales = compare_tags(pila[count-2], cerro); if (tags_son_iguales) { return false; } count -= 2; } return true; }
bool NoteUpdate::basically_equal_to(const Note::Ptr & existing_note) { // NOTE: This would be so much easier if NoteUpdate // was not just a container for a big XML string sharp::XmlReader xml; xml.load_buffer(m_xml_content); NoteData *data = new NoteData(m_uuid); NoteArchiver::obj().read(xml, *data); std::auto_ptr<NoteData> update_data(data); xml.close(); // NOTE: Mostly a hack to ignore missing version attributes std::string existing_inner_content = get_inner_content(existing_note->data().text()); std::string update_inner_content = get_inner_content(update_data->text()); return existing_inner_content == update_inner_content && existing_note->data().title() == update_data->title() && compare_tags(existing_note->data().tags(), update_data->tags()); // TODO: Compare open-on-startup, pinned }
/* Return -1 if not found 1 if OK 0 if an error occured */ static gint comparse_stream (GstMediaDescriptor * ref, StreamNode * rstream, StreamNode * cstream) { if (g_strcmp0 (rstream->id, cstream->id) == 0) { if (!gst_caps_is_equal (rstream->caps, cstream->caps)) { gchar *rcaps = gst_caps_to_string (rstream->caps), *ccaps = gst_caps_to_string (cstream->caps); GST_VALIDATE_REPORT (ref, FILE_PROFILE_INCORRECT, "Reference descriptor for stream %s has caps: %s" " but compared stream %s has caps: %s", rstream->id, rcaps, cstream->id, ccaps); g_free (rcaps); g_free (ccaps); return 0; } compare_tags (ref, rstream, cstream); return 1; } return -1; }
int validate(char* text, char** errmsg) { // esta pila va a ser el sp en assembly por lo que no vamos a tener que preocuparnos por su tamaño char** pila = malloc(sizeof(char*) * strlen(text)); //count cantida de tags abiertos long count = 0; //numero de linea int nro_linea = 0; int i = 0; while (text[i] != '\0') { if (text[i] == '\n') { nro_linea++; } if (text[i] == '<') { i++; if (text[i] != '\\') { //printf("encontre abierto "); //print_tagg(&text[i+1]); // guardo posicion en donde esta el inicio del tag pila[count] = &text[i]; count++; // no importa este warning pila[count] = nro_linea; count++; } else { // verifico que este bien cerrado // pos donde se abrio el tag char* abrio = pila[count - 2]; i++; //pos donde empieza el tag que cierra char* cerro = &text[i]; // solo para debug //printf("encontre cerrado "); //print_tagg(cerro); bool son_iguales = compare_tags(abrio, cerro); if (son_iguales == false) { // ve si es tagl mal anidado o tag sin abrir while (count != 0) { count -= 2; bool tags_son_iguales = compare_tags(pila[count], cerro); if (tags_son_iguales) { //es tag mal anidado write_error(2, abrio, cerro, nro_linea, errmsg); free(pila); return 1; } } // es tag sin abrir write_error(1, abrio, cerro, nro_linea, errmsg); free(pila); return 1; } //si, esta bien cerrado count-=2; } } i++; } if (count > 0) { // hay tags que no estan cerrados, ya que la "pila" sigue teniendo tags que no fueron cerrados write_error(3, pila[0], NULL, (int) pila[1], errmsg); free(pila); return 1; } printf("todo ok\n"); free(pila); return 0; }