mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	New XML format for saving dives
This patch makes the trips nest, and it also fixes the fact that you never saved the trip notes (you could edit it, but saving would throw it away). I did *not* change the indentation of the dives, so the trip stuff shows up the the beginning of the line, at the same level as the <dive> and <dives> thing. I think it's fairly readable xml, though, and we haven't really had proper "indentation shows nesting" anyway, since the top-level "<dives>" thing also didn't indent stuff inside of it. Anyway, the way I wrote it, it still parses your old "INTRIP" stuff etc, so as far as I know, it should happily read the old-style XML too. At least it seemed to work with your xml file that already had the old-style one (I haven't committed my divetrips, exactly because I didn't like the new format). It always saves in the new style, though. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									946d9c7166
								
							
						
					
					
						commit
						3244a828f3
					
				
					 2 changed files with 40 additions and 14 deletions
				
			
		
							
								
								
									
										20
									
								
								parse-xml.c
									
										
									
									
									
								
							
							
						
						
									
										20
									
								
								parse-xml.c
									
										
									
									
									
								
							|  | @ -1171,13 +1171,20 @@ static void dive_start(void) | |||
| 		return; | ||||
| 	cur_dive = alloc_dive(); | ||||
| 	memset(&cur_tm, 0, sizeof(cur_tm)); | ||||
| 	if (cur_trip) { | ||||
| 		cur_dive->divetrip = cur_trip; | ||||
| 		cur_dive->tripflag = IN_TRIP; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| static void dive_end(void) | ||||
| { | ||||
| 	if (!is_dive()) | ||||
| 	if (!cur_dive) | ||||
| 		return; | ||||
| 	record_dive(cur_dive); | ||||
| 	if (!is_dive()) | ||||
| 		free(cur_dive); | ||||
| 	else | ||||
| 		record_dive(cur_dive); | ||||
| 	cur_dive = NULL; | ||||
| 	cur_cylinder_index = 0; | ||||
| 	cur_ws_index = 0; | ||||
|  | @ -1187,6 +1194,7 @@ static void trip_start(void) | |||
| { | ||||
| 	if (cur_trip) | ||||
| 		return; | ||||
| 	dive_end(); | ||||
| 	cur_trip = calloc(sizeof(dive_trip_t),1); | ||||
| 	memset(&cur_tm, 0, sizeof(cur_tm)); | ||||
| } | ||||
|  | @ -1262,14 +1270,14 @@ static void entry(const char *name, int size, const char *raw) | |||
| 		try_to_fill_sample(cur_sample, name, buf); | ||||
| 		return; | ||||
| 	} | ||||
| 	if (cur_trip) { | ||||
| 		try_to_fill_trip(&cur_trip, name, buf); | ||||
| 		return; | ||||
| 	} | ||||
| 	if (cur_dive) { | ||||
| 		try_to_fill_dive(&cur_dive, name, buf); | ||||
| 		return; | ||||
| 	} | ||||
| 	if (cur_trip) { | ||||
| 		try_to_fill_trip(&cur_trip, name, buf); | ||||
| 		return; | ||||
| 	} | ||||
| 	free(buf); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue