[med-svn] [nut-nutrition] 02/08: Imported nut 14.4

Iain Learmonth irl-guest at moszumanska.debian.org
Fri Jun 6 22:44:44 UTC 2014


This is an automated email from the git hooks/post-receive script.

irl-guest pushed a commit to branch master
in repository nut-nutrition.

commit 44f62be6c8d4ab46554ef8f97e9eda182a4c5827
Author: Wesley J. Landaker <wjl at icecavern.net>
Date:   Sun Apr 12 12:26:47 2009 -0600

    Imported nut 14.4
---
 README    |  6 +++---
 db.h      |  4 ++--
 food.c    |  2 +-
 meal.c    | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
 meal.h    |  2 +-
 nut.1     |  7 +++++-
 nut.html  |  9 ++++++--
 options.c |  9 ++++----
 8 files changed, 90 insertions(+), 23 deletions(-)

diff --git a/README b/README
index 9ada594..907e103 100644
--- a/README
+++ b/README
@@ -54,13 +54,13 @@ Note:  NUT can modify your prior release database files automatically, from
 
 1)  Untar the archive:
 
-	tar xvzf nut-14.3.tar.gz
-	cd nut-14.3/
+	tar xvzf nut-14.4.tar.gz
+	cd nut-14.4/
 
 2)  Consider where you want to put the raw data files.  In the Makefile, find
     the line:
 
-CFLAGS= -O3 -s -Wall -DNUTDIR=\".nutdb\" -DFOODDIR=\"/usr/local/lib/nut\" -ansi -pedantic
+CFLAGS= -Os -s -Wall -DNUTDIR=\".nutdb\" -DFOODDIR=\"/usr/local/lib/nut\" -ansi -pedantic
     
     You may redefine "FOODDIR" as shown on the Makefile line, and then 
     create the directory if necessary, and move the contents of the "raw.data"
diff --git a/db.h b/db.h
index 054ebc7..17b5525 100644
--- a/db.h
+++ b/db.h
@@ -23,8 +23,8 @@
 #define DB_H
 
 #define MAJVERSION 14
-#define MINVERSION 3
-#define VERSIONQ "14.3"
+#define MINVERSION 4
+#define VERSIONQ "14.4"
 
 #include <stdio.h>
 #include "food.h"
diff --git a/food.c b/food.c
index 522776f..4468667 100644
--- a/food.c
+++ b/food.c
@@ -140,7 +140,7 @@ DVBase[VITD] = 400;
 DVBase[LA] = 4.44;
 DVBase[AA] = 0.2;
 DVBase[OMEGA6] = DVBase[LA] + DVBase[AA];
-DVBase[ALA] = 2.22;
+DVBase[ALA] = 2.77;
 DVBase[EPA] = 0.3;
 DVBase[DHA] = 0.3;
 DVBase[OMEGA3] = DVBase[ALA] + DVBase[EPA] + DVBase[DHA];
diff --git a/meal.c b/meal.c
index 5861653..3e97585 100644
--- a/meal.c
+++ b/meal.c
@@ -173,10 +173,39 @@ return meal_ptr;
 
 void modify_meal(char *meal_date, int meal, int num, char *qty)
 {
-struct meal *m, *meal_ptr = &meal_root;
-int count = 0;
-float newqty;
-while (meal_ptr->next != NULL)
+struct meal *m = NULL, *meal_ptr = &meal_root;
+int count = 0, nut = -1;
+float newqty, total = 0, thiscontrib = 0;
+if (qty != NULL && strcmp(qty,"protein") == 0) nut = PROCNT;
+if (qty != NULL && strcmp(qty,"prot") == 0) nut = PROCNT;
+if (qty != NULL && strcmp(qty,"pro") == 0) nut = PROCNT;
+else if (qty != NULL && strcmp(qty,"carb") == 0) nut = CHO_NONFIB;
+else if (qty != NULL && strcmp(qty,"car") == 0) nut = CHO_NONFIB;
+else if (qty != NULL && strcmp(qty,"fat") == 0) nut = FAT;
+if (nut != -1) while (meal_ptr->next != NULL)
+ {
+ if (strcmp(meal_date,meal_ptr->next->meal_date) == 0 && meal == meal_ptr->next->meal) 
+  {
+  count++;
+  if (count == num) m = meal_ptr;
+  total += options.mealsperday * meal_ptr->next->grams / 100 * FoodIndex[meal_ptr->next->food_no]->nutrient[nut];
+  }
+ meal_ptr = meal_ptr->next;
+ }
+if (nut != -1 && m != NULL)
+ {
+ thiscontrib = options.mealsperday * m->next->grams / 100 * FoodIndex[m->next->food_no]->nutrient[nut];
+ newqty = (thiscontrib + DV[nut] - total) / thiscontrib * m->next->grams;
+ if (newqty <= 0)
+  {
+  meal_ptr = m->next;
+  m->next = m->next->next;
+  free(meal_ptr);
+  }
+ else if (FoodIndex[m->next->food_no]->nutrient[nut] > 0) m->next->grams = newqty;
+ return;
+ }
+if (nut == -1) while (meal_ptr->next != NULL)
  {
  if (strcmp(meal_date,meal_ptr->next->meal_date) == 0 && meal == meal_ptr->next->meal) 
   {
@@ -230,10 +259,39 @@ while (meal_ptr->next != NULL)
 
 void modify_theusual(char *meal_date, int num, char *qty)
 {
-struct meal *m, *theusual_ptr = &theusual_root;
-int count = 0;
-float newqty;
-while (theusual_ptr->next != NULL)
+struct meal *m = NULL, *theusual_ptr = &theusual_root;
+int count = 0, nut = -1;
+float newqty, total = 0, thiscontrib = 0;
+if (qty != NULL && strcmp(qty,"protein") == 0) nut = PROCNT;
+if (qty != NULL && strcmp(qty,"prot") == 0) nut = PROCNT;
+if (qty != NULL && strcmp(qty,"pro") == 0) nut = PROCNT;
+else if (qty != NULL && strcmp(qty,"carb") == 0) nut = CHO_NONFIB;
+else if (qty != NULL && strcmp(qty,"car") == 0) nut = CHO_NONFIB;
+else if (qty != NULL && strcmp(qty,"fat") == 0) nut = FAT;
+if (nut != -1) while (theusual_ptr->next != NULL)
+ {
+ if (strcmp(meal_date,theusual_ptr->next->meal_date) == 0) 
+  {
+  count++;
+  if (count == num) m = theusual_ptr;
+  total += options.mealsperday * theusual_ptr->next->grams / 100 * FoodIndex[theusual_ptr->next->food_no]->nutrient[nut];
+  }
+ theusual_ptr = theusual_ptr->next;
+ }
+if (nut != -1 && m != NULL)
+ {
+ thiscontrib = options.mealsperday * m->next->grams / 100 * FoodIndex[m->next->food_no]->nutrient[nut];
+ newqty = (thiscontrib + DV[nut] - total) / thiscontrib * m->next->grams;
+ if (newqty <= 0)
+  {
+  theusual_ptr = m->next;
+  m->next = m->next->next;
+  free(theusual_ptr);
+  }
+ else if (FoodIndex[m->next->food_no]->nutrient[nut] > 0) m->next->grams = newqty;
+ return;
+ }
+if (nut == -1) while (theusual_ptr->next != NULL)
  {
  if (strcmp(meal_date,theusual_ptr->next->meal_date) == 0) 
   {
diff --git a/meal.h b/meal.h
index 5b142d4..a07ff95 100644
--- a/meal.h
+++ b/meal.h
@@ -46,7 +46,7 @@ struct meal *theusual_find(char *);
 struct meal *prev_meal(struct meal *);
 void modify_meal(char *, int, int, char *);
 void delete_meal_with_ptr(struct meal *);
-void modify_theusual(char *,int, char *);
+void modify_theusual(char *, int, char *);
 void delete_theusual_with_ptr(struct meal *);
 int meal_count(struct meal *);
 void delete_meals(int);
diff --git a/nut.1 b/nut.1
index 12ec8af..a702381 100644
--- a/nut.1
+++ b/nut.1
@@ -4,7 +4,7 @@
 .\" LP paragraph
 .\" IP indented paragraph
 .\" TP hanging label
-.TH "nut" "1" "2009.02.07" "" ""
+.TH "nut" "1" "2009.04.12" "" ""
 .SH "NAME"
 .B nut \- analyze meals with the USDA Nutrient Database
 .SH "SYNOPSIS"
@@ -60,6 +60,11 @@ by entering the food number shown, but you can also modify
 the quantity by typing the food number and a new quantity,
 for example
 "2 100g", i.e. change food #2 to 100 grams.
+Another way to change the quantity is to type "protein", 
+"carb", or "fat" instead of an explicit new quantity; for
+example, "2 carb" indicates you want the 
+second food's quantity changed
+so that the meal's Daily Value for non-fiber carb is satisfied.
 For the analysis to come out right you must record 
 all the meals the program is set for.  
 For instance, if set for three meals, and
diff --git a/nut.html b/nut.html
index f0d6bc7..9706505 100644
--- a/nut.html
+++ b/nut.html
@@ -3,7 +3,7 @@ Content-type: text/html
 <HTML><HEAD><TITLE>Manpage of nut</TITLE>
 </HEAD><BODY>
 <H1>nut</H1>
-Section:  (1)<BR>Updated: 2009.02.07<BR><A HREF="#index">Index</A>
+Section:  (1)<BR>Updated: 2009.04.12<BR><A HREF="#index">Index</A>
 <A HREF="http://localhost/cgi-bin/man/man2html">Return to Main Contents</A><HR>
 
 <A NAME="lbAB"> </A>
@@ -73,6 +73,11 @@ by entering the food number shown, but you can also modify
 the quantity by typing the food number and a new quantity,
 for example
 "2 100g", i.e. change food #2 to 100 grams.
+Another way to change the quantity is to type "protein", 
+"carb", or "fat" instead of an explicit new quantity; for
+example, "2 carb" indicates you want the 
+second food's quantity changed
+so that the meal's Daily Value for non-fiber carb is satisfied.
 For the analysis to come out right you must record 
 all the meals the program is set for.  
 For instance, if set for three meals, and
@@ -357,6 +362,6 @@ Copyright (C) 1996-2009 by Jim Jozwiak.
 This document was created by
 <A HREF="http://localhost/cgi-bin/man/man2html">man2html</A>,
 using the manual pages.<BR>
-Time: 23:52:34 GMT, February 07, 2009
+Time: 21:24:32 GMT, April 11, 2009
 </BODY>
 </HTML>
diff --git a/options.c b/options.c
index 3544b7e..ca74637 100644
--- a/options.c
+++ b/options.c
@@ -29,7 +29,7 @@
 
 struct opt options;
 
-static float DefaultTarget = 90, DefaultEPADHA = 0.6;
+static float DefaultTarget = 90, DefaultEPADHA = 0.7;
 
 void initialize_options()
 {
@@ -607,7 +607,8 @@ if (options.epadhamax <= 0) epadhalimit = DefaultEPADHA;
 else epadhalimit = options.epadhamax;
 
 options.abnuts[ALA] = food_work.nutrient[ALA];
-if (options.abnuts[ALA] <= 0) options.abnuts[ALA] = .00001;
+if (options.abnuts[ALA] < DV[ALA]) options.abnuts[ALA] = DV[ALA];
+extra_ala = options.abnuts[ALA] - food_work.nutrient[ALA];
 
 if ( (DefaultTarget == 90 && options.n6hufa == 0) || options.n6hufa == 90 || options.n6hufa == 15)
  {
@@ -617,10 +618,8 @@ if ( (DefaultTarget == 90 && options.n6hufa == 0) || options.n6hufa == 90 || opt
  if (options.abnuts[LA] <= 0) options.abnuts[LA] = .00001;
  options.abnuts[AA] = food_work.nutrient[AA];
  if (options.abnuts[AA] <= 0) options.abnuts[AA] = .00001;
- options.abnuts[OMEGA3] = food_work.nutrient[OMEGA3];
+ options.abnuts[OMEGA3] = food_work.nutrient[OMEGA3] + extra_ala;
  if (options.abnuts[OMEGA3] <= 0) options.abnuts[OMEGA3] = .00001;
- options.abnuts[ALA] = food_work.nutrient[ALA];
- if (options.abnuts[ALA] <= 0) options.abnuts[ALA] = .00001;
  options.abnuts[EPA] = food_work.nutrient[EPA];
  if (options.abnuts[EPA] <= 0) options.abnuts[EPA] = .00001;
  options.abnuts[DHA] = food_work.nutrient[DHA];

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/nut-nutrition.git



More information about the debian-med-commit mailing list